ZQuest Classic Coverage Report


Directory: src/
File: src/zc/script_drawing.cpp
Date: 2026-01-24 00:14:48
Exec Total Coverage
Lines: 1494 5760 25.9%
Functions: 54 108 50.0%
Branches: 638 2970 21.5%

Line Branch Exec Source
1 //! ritate_sprite_trans doesn't seem to be supported by or allegro header !?
2
3 //glibc 2.28 and later require this: -Z
4 #include <optional>
5 #include <utility>
6 #ifdef __GNUG__
7 #define ALLEGRO_NO_FIX_ALIASES
8 #endif
9
10 #include "base/qrs.h"
11 #include "base/dmap.h"
12 #include "base/zdefs.h"
13 #include "base/zc_alleg.h"
14 #include "zc/script_drawing.h"
15 #include "zc/rendertarget.h"
16 #include "zc/maps.h"
17 #include "tiles.h"
18 #include "zc/zelda.h"
19 #include "zc/ffscript.h"
20 #include "base/util.h"
21 #include "subscr.h"
22 #include "drawing.h"
23 #include "base/mapscr.h"
24 #include "base/misctypes.h"
25 using namespace util;
26 extern refInfo *ri;
27 extern script_bitmaps scb;
28 #include <stdio.h>
29 #include <fstream>
30
31 static int32_t secondary_draw_origin_xoff;
32 static int32_t secondary_draw_origin_yoff;
33
34 126335494 static std::optional<std::pair<int, int>> get_draw_origin_offset(DrawOrigin draw_origin, int draw_origin_target_uid, int xoff, int yoff)
35 {
36 int xoffset;
37 int yoffset;
38
2/2
✓ Branch 0 taken 41428 times.
✓ Branch 1 taken 126294066 times.
126335494 if (draw_origin == DrawOrigin::Region)
39 {
40 41428 xoffset = xoff - viewport.x;
41 41428 yoffset = yoff - viewport.y;
42 41428 }
43
2/2
✓ Branch 0 taken 8072 times.
✓ Branch 1 taken 126285994 times.
126294066 else if (draw_origin == DrawOrigin::RegionScrollingNew)
44 {
45 8072 xoffset = xoff + FFCore.ScrollingData[SCROLLDATA_NRX];
46 8072 yoffset = yoff + FFCore.ScrollingData[SCROLLDATA_NRY];
47 8072 }
48
2/2
✓ Branch 0 taken 105315950 times.
✓ Branch 1 taken 20970044 times.
126285994 else if (draw_origin == DrawOrigin::PlayingField)
49 {
50 105315950 xoffset = xoff;
51 105315950 yoffset = yoff;
52 105315950 }
53
2/2
✓ Branch 0 taken 20963933 times.
✓ Branch 1 taken 6111 times.
20970044 else if (draw_origin == DrawOrigin::Screen)
54 {
55 20963933 xoffset = 0;
56 20963933 yoffset = 0;
57 20963933 }
58
1/2
✓ Branch 0 taken 6111 times.
✗ Branch 1 not taken.
6111 else if (draw_origin == DrawOrigin::Sprite)
59 {
60 6111 sprite* draw_origin_target = sprite::getByUID(draw_origin_target_uid);
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6111 times.
6111 if (!draw_origin_target)
62 {
63 Z_scripterrlog("Warning: Ignoring draw command using DRAW_ORIGIN_SPRITE with non-existent sprite uid: %d.\n", draw_origin_target_uid);
64 return std::nullopt;
65 }
66
67 6111 xoffset = xoff - viewport.x + draw_origin_target->x.getInt();
68 6111 yoffset = yoff - viewport.y + draw_origin_target->y.getInt();
69 6111 }
70 else
71 {
72 // Unexpected.
73 xoffset = 0;
74 yoffset = 0;
75 }
76
77 126335494 return std::make_pair(xoffset, yoffset);
78 126335494 }
79
80 24646067 std::pair<int, bool> resolveScriptingBitmapId(int scripting_bitmap_id)
81 {
82
4/6
✓ Branch 0 taken 3396548 times.
✓ Branch 1 taken 21249519 times.
✓ Branch 2 taken 3396548 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3396548 times.
✗ Branch 5 not taken.
24646067 if ((scripting_bitmap_id % 10000 == 0) && (scripting_bitmap_id >= -20000 && scripting_bitmap_id <= 60000))
83 {
84 // Handles zscript values for RT_SCREEN, RT_BITMAP0, etc.
85 3396548 return {scripting_bitmap_id / 10000, false};
86 }
87
3/4
✓ Branch 0 taken 21249519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13106128 times.
✓ Branch 3 taken 8143391 times.
21249519 else if (scripting_bitmap_id - 10 >= -2 && scripting_bitmap_id - 10 <= rtBMP6)
88 {
89 // Handles Game->LoadBitmapID, which sets the bitmap pointer as a "long" int.
90 8143391 return {scripting_bitmap_id - 10, false};
91 }
92 else
93 {
94 // This is a user bitmap.
95 13106128 return {scripting_bitmap_id, true};
96 }
97 24646067 }
98
99 static BITMAP* current_target_bmp;
100
101 68364336 static BITMAP* resolveScriptingBitmap(int scripting_bitmap_id)
102 {
103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68364336 times.
68364336 if (scripting_bitmap_id < 0)
104 {
105 // Handles zscript values for RT_SCREEN, etc.
106 return FFCore.GetScriptBitmap((scripting_bitmap_id / 10000) + 10, current_target_bmp);
107 }
108 else
109 {
110 // Handles Game->LoadBitmapID, which sets the bitmap pointer as a "long" int.
111 // Also handles user bitmaps.
112 68364336 return FFCore.GetScriptBitmap(scripting_bitmap_id, current_target_bmp);
113 }
114 68364336 }
115
116 inline double sd_log2( double n )
117 {
118 // log(n)/log(2) is log2.
119 double v = log( (double)n ) / log( (double)2 );
120 return v;
121 }
122
123 inline bool isPowerOfTwo(int32_t n)
124 {
125 if(n==0)
126 return false;
127
128 return (ceil(sd_log2(n)) == floor(sd_log2(n)));
129 }
130
131 BITMAP* ScriptDrawingBitmapPool::_parent_bmp = 0;
132
133 class TileHelper
134 {
135 public:
136
137 46094 static void OldPutTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
138 {
139 // Past the end of the tile page?
140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46094 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46094 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
141 {
142 byte w2=(tile+w)%TILES_PER_ROW;
143 OldPutTile(_Dest, tile, x, y, w-w2, h, color, flip);
144 OldPutTile(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip);
145 return;
146 }
147
148
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 46094 times.
46094 switch(flip)
149 {
150 case 1:
151 for(int32_t j=0; j<h; j++)
152 for(int32_t k=w-1; k>=0; k--)
153 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip);
154
155 break;
156
157 case 2:
158 for(int32_t j=h-1; j>=0; j--)
159 for(int32_t k=0; k<w; k++)
160 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip);
161
162 break;
163
164 case 3:
165 for(int32_t j=h-1; j>=0; j--)
166 for(int32_t k=w-1; k>=0; k--)
167 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip);
168
169 break;
170
171 46094 case 0:
172 default:
173
2/2
✓ Branch 0 taken 181240 times.
✓ Branch 1 taken 46094 times.
227334 for(int32_t j=0; j<h; j++)
174
2/2
✓ Branch 0 taken 1111148 times.
✓ Branch 1 taken 181240 times.
1292388 for(int32_t k=0; k<w; k++)
175 1292388 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip);
176
177 46094 break;
178 }
179 46094 }
180
181 4793800 static void OverTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
182 {
183 4793800 overtileblock16(_Dest,tile,x,y,w,h,color,flip,skiprows);
184 4793800 }
185
186 static void OverTileCloaked(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t flip, byte skiprows=0)
187 {
188 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
189 {
190 byte w2=(tile+w)%TILES_PER_ROW;
191 OverTileCloaked(_Dest, tile, x, y, w-w2, h, flip);
192 OverTileCloaked(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, flip);
193 return;
194 }
195
196 switch(flip)
197 {
198 case 1:
199 for(int32_t j=0; j<h; j++)
200 for(int32_t k=w-1; k>=0; k--)
201 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, flip);
202
203 break;
204
205 case 2:
206 for(int32_t j=h-1; j>=0; j--)
207 for(int32_t k=0; k<w; k++)
208 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, flip);
209
210 break;
211
212 case 3:
213 for(int32_t j=h-1; j>=0; j--)
214 for(int32_t k=w-1; k>=0; k--)
215 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, flip);
216
217 break;
218
219 default:
220 for(int32_t j=0; j<h; j++)
221 for(int32_t k=0; k<w; k++)
222 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, flip);
223
224 break;
225 }
226 }
227
228 289390 static void OverTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
229 {
230
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 289390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
289390 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
231 {
232 byte w2=(tile+w)%TILES_PER_ROW;
233 OverTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
234 OverTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
235 return;
236 }
237
238
1/4
✓ Branch 0 taken 289390 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
289390 switch(flip)
239 {
240 case 1:
241 for(int32_t j=0; j<h; j++)
242 for(int32_t k=w-1; k>=0; k--)
243 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
244
245 break;
246
247 case 2:
248 for(int32_t j=h-1; j>=0; j--)
249 for(int32_t k=0; k<w; k++)
250 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
251
252 break;
253
254 case 3:
255 for(int32_t j=h-1; j>=0; j--)
256 for(int32_t k=w-1; k>=0; k--)
257 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
258
259 break;
260
261 default:
262
2/2
✓ Branch 0 taken 1672950 times.
✓ Branch 1 taken 289390 times.
1962340 for(int32_t j=0; j<h; j++)
263
2/2
✓ Branch 0 taken 23552575 times.
✓ Branch 1 taken 1672950 times.
25225525 for(int32_t k=0; k<w; k++)
264 25225525 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
265
266 289390 break;
267 }
268 289390 }
269
270 static void PutTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
271 {
272 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
273 {
274 byte w2=(tile+w)%TILES_PER_ROW;
275 PutTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
276 PutTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
277 return;
278 }
279
280 switch(flip)
281 {
282 case 1:
283 for(int32_t j=0; j<h; j++)
284 for(int32_t k=w-1; k>=0; k--)
285 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
286
287 break;
288
289 case 2:
290 for(int32_t j=h-1; j>=0; j--)
291 for(int32_t k=0; k<w; k++)
292 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
293
294 break;
295
296 case 3:
297 for(int32_t j=h-1; j>=0; j--)
298 for(int32_t k=w-1; k>=0; k--)
299 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
300
301 break;
302
303 default:
304 for(int32_t j=0; j<h; j++)
305 for(int32_t k=0; k<w; k++)
306 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
307
308 break;
309 }
310 }
311 };
312
313
314
315
316 3344855 void do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
317 {
318 //sdci[1]=layer
319 //sdci[2]=x
320 //sdci[3]=y
321 //sdci[4]=x2
322 //sdci[5]=y2
323 //sdci[6]=color
324 //sdci[7]=scale factor
325 //sdci[8]=rotation anchor x
326 //sdci[9]=rotation anchor y
327 //sdci[10]=rotation angle
328 //sdci[11]=fill
329 //sdci[12]=opacity
330
1/2
✓ Branch 0 taken 3344855 times.
✗ Branch 1 not taken.
3344855 if(sdci[7]==0) //scale
331 {
332 return;
333 }
334
335 3344855 int32_t x1=sdci[2]/10000;
336 3344855 int32_t y1=sdci[3]/10000;
337 3344855 int32_t x2=sdci[4]/10000;
338 3344855 int32_t y2=sdci[5]/10000;
339
340
1/2
✓ Branch 0 taken 3344855 times.
✗ Branch 1 not taken.
3344855 if(x1>x2)
341 {
342 zc_swap(x1,x2);
343 }
344
345
2/2
✓ Branch 0 taken 3325339 times.
✓ Branch 1 taken 19516 times.
3344855 if(y1>y2)
346 {
347 19516 zc_swap(y1,y2);
348 19516 }
349
350
2/2
✓ Branch 0 taken 3342035 times.
✓ Branch 1 taken 2820 times.
3344855 if(sdci[7] != 10000)
351 {
352 2820 int32_t w=x2-x1+1;
353 2820 int32_t h=y2-y1+1;
354 2820 int32_t w2=(w*sdci[7])/10000;
355 2820 int32_t h2=(h*sdci[7])/10000;
356 2820 x1=x1-((w2-w)/2);
357 2820 x2=x2+((w2-w)/2);
358 2820 y1=y1-((h2-h)/2);
359 2820 y2=y2+((h2-h)/2);
360 2820 }
361
362 3344855 int32_t color=sdci[6]/10000;
363
364
2/2
✓ Branch 0 taken 3308009 times.
✓ Branch 1 taken 36846 times.
3344855 if(sdci[12]/10000<=127) //translucent
365 {
366 36846 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
367 36846 }
368
369
2/2
✓ Branch 0 taken 82060 times.
✓ Branch 1 taken 3262795 times.
3344855 if(sdci[10]==0) //no rotation
370 {
371
2/2
✓ Branch 0 taken 838727 times.
✓ Branch 1 taken 2424068 times.
3262795 if(sdci[11]) //filled
372 {
373 2424068 rectfill(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
374 2424068 }
375 else //outline
376 {
377 838727 rect(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
378 }
379 3262795 }
380 else //rotate
381 {
382 int32_t xy[16];
383 82060 int32_t rx=sdci[8]/10000;
384 82060 int32_t ry=sdci[9]/10000;
385 82060 fixed ra1=itofix(sdci[10]%10000)/10000;
386 82060 fixed ra2=itofix(sdci[10]/10000);
387 82060 fixed ra=ra1+ra2;
388 82060 ra = (ra/360)*256;
389
390 82060 fixed fcosa = fixcos(ra);
391 82060 fixed fsina = fixsin(ra);
392
393 82060 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
394 82060 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
395 82060 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
396 82060 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
397 82060 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
398 82060 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
399 82060 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
400 82060 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
401 82060 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
402 82060 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
403 82060 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
404 82060 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
405 82060 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
406 82060 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
407 82060 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
408 82060 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
409
410
1/2
✓ Branch 0 taken 82060 times.
✗ Branch 1 not taken.
82060 if(sdci[11]) //filled
411 {
412 82060 polygon(bmp, 4, xy, color);
413 82060 }
414 else //outline
415 {
416 line(bmp, xy[0], xy[1], xy[10], xy[11], color);
417 line(bmp, xy[2], xy[3], xy[12], xy[13], color);
418 line(bmp, xy[4], xy[5], xy[14], xy[15], color);
419 line(bmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
420 }
421 }
422
423 3344855 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
424 3344855 }
425
426 void do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
427 {
428 //sdci[1]=layer
429 //sdci[2]=x
430 //sdci[3]=y
431 //sdci[4]=tile
432 //sdci[5]=cset
433 //sdci[6]=width
434 //sdci[7]=height
435 //sdci[8]=overlay
436 //sdci[9]=opacity
437
438 int32_t x=sdci[2]/10000;
439 int32_t y=sdci[3]/10000;
440
441 int32_t tile=sdci[4]/10000;
442 int32_t cs=sdci[5]/10000;
443 int32_t w=sdci[6]/10000;
444 int32_t h=sdci[7]/10000;
445 bool overlay=sdci[8];
446 bool trans=(sdci[9]/10000<=127);
447
448 frame2x2(bmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
449 }
450
451
452
453 1170681 void do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
454 {
455 //sdci[1]=layer
456 //sdci[2]=x
457 //sdci[3]=y
458 //sdci[4]=radius
459 //sdci[5]=color
460 //sdci[6]=scale factor
461 //sdci[7]=rotation anchor x
462 //sdci[8]=rotation anchor y
463 //sdci[9]=rotation angle
464 //sdci[10]=fill
465 //sdci[11]=opacity
466
1/2
✓ Branch 0 taken 1170681 times.
✗ Branch 1 not taken.
1170681 if(sdci[6]==0) //scale
467 {
468 return;
469 }
470
471 1170681 int32_t x1=sdci[2]/10000;
472 1170681 int32_t y1=sdci[3]/10000;
473 1170681 qword r=sdci[4];
474
475
1/2
✓ Branch 0 taken 1170681 times.
✗ Branch 1 not taken.
1170681 if(sdci[6] != 10000)
476 {
477 r*=sdci[6];
478 r/=10000;
479 }
480
481 1170681 r/=10000;
482 1170681 int32_t color=sdci[5]/10000;
483
484
2/2
✓ Branch 0 taken 989374 times.
✓ Branch 1 taken 181307 times.
1170681 if(sdci[11]/10000<=127) //translucent
485 {
486 181307 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
487 181307 }
488
489
5/6
✓ Branch 0 taken 58575 times.
✓ Branch 1 taken 1112106 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 57231 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1344 times.
1170681 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
490 {
491 int32_t xy[2];
492 57231 int32_t rx=sdci[7]/10000;
493 57231 int32_t ry=sdci[8]/10000;
494 57231 fixed ra1=itofix(sdci[9]%10000)/10000;
495 57231 fixed ra2=itofix(sdci[9]/10000);
496 57231 fixed ra=ra1+ra2;
497 57231 ra = (ra/360)*256;
498
499 57231 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
500 57231 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
501 57231 x1=xy[0];
502 57231 y1=xy[1];
503 57231 }
504
505
2/2
✓ Branch 0 taken 1153667 times.
✓ Branch 1 taken 17014 times.
1170681 if(sdci[10]) //filled
506 {
507 1153667 circlefill(bmp, x1+xoffset, y1+yoffset, r, color);
508 1153667 }
509 else //outline
510 {
511 17014 circle(bmp, x1+xoffset, y1+yoffset, r, color);
512 }
513
514 1170681 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
515 1170681 }
516
517
518 void do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
519 {
520 //sdci[1]=layer
521 //sdci[2]=x
522 //sdci[3]=y
523 //sdci[4]=radius
524 //sdci[5]=start angle
525 //sdci[6]=end angle
526 //sdci[7]=color
527 //sdci[8]=scale factor
528 //sdci[9]=rotation anchor x
529 //sdci[10]=rotation anchor y
530 //sdci[11]=rotation angle
531 //sdci[12]=closed
532 //sdci[13]=fill
533 //sdci[14]=opacity
534
535 if(sdci[8]==0) //scale
536 {
537 return;
538 }
539
540 int32_t cx=sdci[2]/10000;
541 int32_t cy=sdci[3]/10000;
542 qword r=sdci[4];
543
544 if(sdci[8] != 10000)
545 {
546 r*=sdci[8];
547 r/=10000;
548 }
549
550 r/=10000;
551
552 int32_t color=sdci[7]/10000;
553
554 fixed ra1=itofix(sdci[11]%10000)/10000;
555 fixed ra2=itofix(sdci[11]/10000);
556 fixed ra=ra1+ra2;
557 ra = (ra/360)*256;
558
559
560 fixed a1=itofix(sdci[5]%10000)/10000;
561 fixed a2=itofix(sdci[5]/10000);
562 fixed sa=a1+a2;
563 sa = (sa/360)*256;
564
565 a1=itofix(sdci[6]%10000)/10000;
566 a2=itofix(sdci[6]/10000);
567 fixed ea=a1+a2;
568 ea = (ea/360)*256;
569
570 if(sdci[11]!=0) //rotation
571 {
572 int32_t rx=sdci[9]/10000;
573 int32_t ry=sdci[10]/10000;
574
575 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
576 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
577 ea-=ra;
578 sa-=ra;
579 }
580
581 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
582 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
583
584 if(sdci[12]) //closed
585 {
586 if(sdci[13]) //filled
587 {
588 clear_bitmap(prim_bmp);
589 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
590 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
591 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
592 int fillx = zc_max(0,fx)+xoffset;
593 int filly = zc_max(0,fy)+yoffset;
594 zprint2("Screen->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
595 floodfill(prim_bmp, fillx, filly, color);
596
597 if(sdci[14]/10000<=127) //translucent
598 {
599 draw_trans_sprite(bmp, prim_bmp, 0,0);
600 }
601 else
602 {
603 draw_sprite(bmp, prim_bmp, 0,0);
604 }
605 }
606 else
607 {
608 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
609 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
610 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
611 }
612 }
613 else
614 {
615 if(sdci[14]/10000<=127) //translucent
616 {
617 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
618 }
619
620 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
621 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
622 }
623 }
624
625
626 1850 void do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
627 {
628 //sdci[1]=layer
629 //sdci[2]=x
630 //sdci[3]=y
631 //sdci[4]=radiusx
632 //sdci[5]=radiusy
633 //sdci[6]=color
634 //sdci[7]=scale factor
635 //sdci[8]=rotation anchor x
636 //sdci[9]=rotation anchor y
637 //sdci[10]=rotation angle
638 //sdci[11]=fill
639 //sdci[12]=opacity
640
641
1/2
✓ Branch 0 taken 1850 times.
✗ Branch 1 not taken.
1850 if(sdci[7]==0) //scale
642 {
643 return;
644 }
645
646 1850 int32_t x1=sdci[2]/10000;
647 1850 int32_t y1=sdci[3]/10000;
648 1850 int32_t radx=sdci[4]/10000;
649 1850 radx*=sdci[7]/10000;
650 1850 int32_t rady=sdci[5]/10000;
651 1850 rady*=sdci[7]/10000;
652 1850 int32_t color=sdci[6]/10000;
653 1850 float rotation = sdci[10]/10000;
654
655 1850 int32_t rx=sdci[8]/10000;
656 1850 int32_t ry=sdci[9]/10000;
657 1850 fixed ra1=itofix(sdci[10]%10000)/10000;
658 1850 fixed ra2=itofix(sdci[10]/10000);
659 1850 fixed ra=ra1+ra2;
660 1850 ra = (ra/360)*256;
661
662 int32_t xy[2];
663 1850 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
664 1850 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
665 1850 x1=xy[0];
666 1850 y1=xy[1];
667
668
6/8
✓ Branch 0 taken 1746 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1687 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 1687 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1687 times.
1850 if(radx<1||rady<1||radx>255||rady>255) return;
669
670 1687 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
671
672
2/2
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 57 times.
1687 if(sdci[11]) //filled
673 {
674
675
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 606 times.
1630 if(sdci[12]/10000<128) //translucent
676 {
677 1024 clear_bitmap(prim_bmp);
678
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
679 1024 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
680 1024 draw_trans_sprite(bmp, prim_bmp, 0, 0);
681 1024 }
682 else // no opacity
683 {
684
1/2
✓ Branch 0 taken 606 times.
✗ Branch 1 not taken.
606 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
685 606 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
686 }
687 1630 }
688 else //not filled
689 {
690
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 43 times.
57 if(sdci[12]/10000<128) //translucent
691 {
692 14 clear_bitmap(prim_bmp);
693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
694 14 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
695 14 draw_trans_sprite(bmp, prim_bmp, 0, 0);
696 14 }
697 else // no opacity
698 {
699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
700 43 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
701 }
702 }
703
704 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
705 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
706 // the ellipse, but it shouldn't be used anyway.
707
1/2
✓ Branch 0 taken 1687 times.
✗ Branch 1 not taken.
1687 if(color==0)
708 {
709 // This is very slow, so check the smallest possible square
710 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
711 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
712
713 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
714 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
715 if(getpixel(bmp, x, y)==255)
716 putpixel(bmp, x, y, 0);
717 }
718
719 1687 script_drawing_commands.ReleaseSubBitmap(bitty);
720 1850 }
721
722
723 2351475 void do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
724 {
725 //sdci[1]=layer
726 //sdci[2]=x
727 //sdci[3]=y
728 //sdci[4]=x2
729 //sdci[5]=y2
730 //sdci[6]=color
731 //sdci[7]=scale factor
732 //sdci[8]=rotation anchor x
733 //sdci[9]=rotation anchor y
734 //sdci[10]=rotation angle
735 //sdci[11]=opacity
736
1/2
✓ Branch 0 taken 2351475 times.
✗ Branch 1 not taken.
2351475 if(sdci[7]==0) //scale
737 {
738 return;
739 }
740
741 2351475 int32_t x1=sdci[2]/10000;
742 2351475 int32_t y1=sdci[3]/10000;
743 2351475 int32_t x2=sdci[4]/10000;
744 2351475 int32_t y2=sdci[5]/10000;
745
746
2/2
✓ Branch 0 taken 1903153 times.
✓ Branch 1 taken 448322 times.
2351475 if(sdci[7] != 10000)
747 {
748 448322 int32_t w=x2-x1+1;
749 448322 int32_t h=y2-y1+1;
750 448322 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
751 448322 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
752 448322 x1=x1-((w2-w)/2);
753 448322 x2=x2+((w2-w)/2);
754 448322 y1=y1-((h2-h)/2);
755 448322 y2=y2+((h2-h)/2);
756 448322 }
757
758 2351475 int32_t color=sdci[6]/10000;
759
760
1/2
✓ Branch 0 taken 2351475 times.
✗ Branch 1 not taken.
2351475 if(sdci[11]/10000<=127) //translucent
761 {
762 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
763 }
764
765
2/2
✓ Branch 0 taken 939459 times.
✓ Branch 1 taken 1412016 times.
2351475 if(sdci[10]!=0) //rotation
766 {
767 int32_t xy[4];
768 1412016 int32_t rx=sdci[8]/10000;
769 1412016 int32_t ry=sdci[9]/10000;
770 1412016 fixed ra1=itofix(sdci[10]%10000)/10000;
771 1412016 fixed ra2=itofix(sdci[10]/10000);
772 1412016 fixed ra=ra1+ra2;
773
774 1412016 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
775 1412016 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
776 1412016 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
777 1412016 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
778 1412016 x1=xy[0];
779 1412016 y1=xy[1];
780 1412016 x2=xy[2];
781 1412016 y2=xy[3];
782 1412016 }
783
784 2351475 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
785 2351475 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
786 2351475 }
787
788 void do_linesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
789 {
790 //sdci[1]=layer
791 //sdci[2]=array[10] = { x, y, x2, y2, colour, scale, rx, ry, angle, opacity }
792
793 //sdci[2]=x
794 //sdci[3]=y
795 //sdci[4]=x2
796 //sdci[5]=y2
797 //sdci[6]=color
798 //sdci[7]=scale factor
799 //sdci[8]=rotation anchor x
800 //sdci[9]=rotation anchor y
801 //sdci[10]=rotation angle
802 //sdci[11]=opacity
803 //if(sdci[7]==0) //scale
804 //{
805 // return;
806 //}
807
808 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
809
810 if(!v_ptr)
811 {
812 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
813 return;
814 }
815
816 std::vector<int32_t> &v = *v_ptr;
817
818 if(v.empty())
819 return;
820
821 int32_t* pos = &v[0];
822 int32_t sz = v.size();
823
824 for ( int32_t q = 0; q < sz; q+=10 )
825 {
826
827 int32_t x1 = v.at(q);
828 //Z_scripterrlog("Lines( x1 ) is: %d\n", x1);
829 int32_t y1 = v.at(q+1);
830 //Z_scripterrlog("Lines( x2 ) is: %d\n", y1);
831 int32_t x2 = v.at(q+2);
832 //Z_scripterrlog("Lines( x2 ) is: %d\n", x2);
833 int32_t y2 = v.at(q+3);
834 //Z_scripterrlog("Lines( y2 ) is: %d\n", y2);
835 int32_t color = v.at(q+4);
836 //Z_scripterrlog("Lines( colour ) is: %d\n", color);
837 //Z_scripterrlog("Lines( scale ) is: %d\n", v.at(q+5));
838 if (v.at(q+5) == 0) { Z_scripterrlog("Lines() aborting due to scale\n"); return; }//scale
839
840 if( v.at(q+5) != 10000)
841 {
842 int32_t w=x2-x1+1;
843 int32_t h=y2-y1+1;
844 int32_t w2=int32_t(w*((double)v.at(q+5)));
845 int32_t h2=int32_t(h*((double)v.at(q+5)));
846 x1=x1-((w2-w)/2);
847 x2=x2+((w2-w)/2);
848 y1=y1-((h2-h)/2);
849 y2=y2+((h2-h)/2);
850 }
851
852
853 //Z_scripterrlog("Lines( opacity ) is: %d\n", v.at(q+9));
854 if(v.at(q+9) <= 127) //translucent
855 {
856 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
857 }
858 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
859 //Z_scripterrlog("Lines( rotation ) is: %d\n", v.at(q+8));
860 //Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+6));
861 //Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+7));
862 if( v.at(q+8) !=0 ) //rotation
863 {
864 int32_t xy[4];
865
866 int32_t rx = v.at(q+6);
867
868 int32_t ry = v.at(q+7);
869
870 fixed ra1=itofix(v.at(q+8) % 1);
871 fixed ra2=itofix(v.at(q+8));
872 fixed ra=ra1+ra2;
873
874 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
875 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
876 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
877 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
878 x1=xy[0];
879 y1=xy[1];
880 x2=xy[2];
881 y2=xy[3];
882 }
883 //Z_scripterrlog("Lines( xofs ) is: %d\n", xoffset);
884 //Z_scripterrlog("Lines( yofs ) is: %d\n", yoffset);
885 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
886 }
887 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
888 }
889
890 1080 void do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
891 {
892 //sdci[1]=layer
893 //sdci[2]=point count
894 //sdci[3]array[]
895 //sdci[4] = colour
896 //sdci[5] = opacity
897
898 1080 int32_t col = sdci[4]/10000;
899 1080 int32_t op = sdci[5]/10000;
900
901 1080 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
902
903
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(!v_ptr)
904 {
905 al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n");
906 return;
907 }
908
909 1080 std::vector<int32_t> &v = *v_ptr;
910
911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(v.empty())
912 return;
913
914 1080 int32_t* pos = &v[0];
915 1080 int32_t sz = v.size();
916 1080 int32_t numpoints = (sdci[2]/10000);
917
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(sz & 1) --sz; //even amount only
918
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(numpoints > sz/2) //cap to array
919 numpoints = sz/2;
920
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(numpoints < 1)
921 return; //Don't draw 0 or negative point count
922
923
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 1080 times.
7560 for (int32_t i = 0; i < sz; i += 2)
924 {
925 6480 pos[i] += xoffset;
926 6480 pos[i + 1] += yoffset;
927 6480 }
928
929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(op <= 127) //translucent
930 {
931 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
932 }
933 1080 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
934
935 1080 polygon(bmp, numpoints, (int32_t*)pos, col);
936 1080 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
937 1080 }
938
939 void bmp_do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
940 {
941 //sdci[1]=layer
942 //sdci[2]=point count
943 //sdci[3]array[]
944 //sdci[4] = colour
945 //sdci[5] = opacity
946
947 int32_t col = sdci[4]/10000;
948 int32_t op = sdci[5]/10000;
949
950 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
951 {
952 Z_scripterrlog("bitmap->Polygon() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
953 return;
954 }
955 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
956 if ( refbmp == NULL ) return;
957
958 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
959
960 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
961
962 if(!v_ptr)
963 {
964 al_trace("bitmap->Polygon: Vector pointer is null! Internal error. \n");
965 return;
966 }
967
968 std::vector<int32_t> &v = *v_ptr;
969
970 if(v.empty())
971 return;
972
973 int32_t* pos = &v[0];
974 int32_t sz = v.size();
975 int32_t numpoints = (sdci[2]/10000);
976 if(sz & 1) --sz; //even amount only
977 if(numpoints > sz/2) //cap to array
978 numpoints = sz/2;
979 if(numpoints < 1)
980 return; //Don't draw 0 or negative point count
981
982 for (int32_t i = 0; i < sz; i += 2)
983 {
984 pos[i] += xoffset;
985 pos[i + 1] += yoffset;
986 }
987
988 if(op <= 127) //translucent
989 {
990 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
991 }
992 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
993
994 polygon(refbmp, numpoints, (int32_t*)pos, col);
995 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
996 }
997
998 void do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
999 {
1000 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
1001
1002 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
1003 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
1004 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
1005 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
1006 };
1007
1008 if(sdci[11]/10000 < 128) //translucent
1009 {
1010 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1011 }
1012
1013 spline(bmp, points, sdci[10]/10000);
1014
1015 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1016 }
1017
1018
1019 404879 void do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1020 {
1021 //sdci[1]=layer
1022 //sdci[2]=x
1023 //sdci[3]=y
1024 //sdci[4]=color
1025 //sdci[5]=rotation anchor x
1026 //sdci[6]=rotation anchor y
1027 //sdci[7]=rotation angle
1028 //sdci[8]=opacity
1029 404879 int32_t x1=sdci[2]/10000;
1030 404879 int32_t y1=sdci[3]/10000;
1031 404879 int32_t color=sdci[4]/10000;
1032
1033
2/2
✓ Branch 0 taken 404863 times.
✓ Branch 1 taken 16 times.
404879 if(sdci[8]/10000<=127) //translucent
1034 {
1035 16 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1036 16 }
1037
1038
1/2
✓ Branch 0 taken 404879 times.
✗ Branch 1 not taken.
404879 if(sdci[7]!=0) //rotation
1039 {
1040 int32_t xy[2];
1041 int32_t rx=sdci[5]/10000;
1042 int32_t ry=sdci[6]/10000;
1043 fixed ra1=itofix(sdci[7]%10000)/10000;
1044 fixed ra2=itofix(sdci[7]/10000);
1045 fixed ra=ra1+ra2;
1046
1047 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1048 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1049 x1=xy[0];
1050 y1=xy[1];
1051 }
1052
1053 404879 putpixel(bmp, x1+xoffset, y1+yoffset, color);
1054 404879 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1055 404879 }
1056
1057 void do_putpixelsr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1058 {
1059 //Z_scripterrlog("Starting putpixels()%s\n");
1060 //sdci[1]=layer
1061 //sdci[2]=array {x,y,colour,opacity}
1062 //sdci[3]=rotation anchor x
1063 //sdci[4]=rotation anchor y
1064 //sdci[5]=rotation angle
1065
1066
1067 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1068
1069 if(!v_ptr)
1070 {
1071 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1072 return;
1073 }
1074
1075 std::vector<int32_t> &v = *v_ptr;
1076
1077 if(v.empty())
1078 return;
1079
1080 int32_t* pos = &v[0];
1081 int32_t sz = v.size();
1082
1083
1084 int32_t x1 = 0;
1085 int32_t y1 = 0;
1086
1087 for ( int32_t q = 0; q < sz; q+=4 )
1088 {
1089 x1 = v.at(q); //pos[q];
1090 y1 = v.at(q+1); //pos[q+1];
1091 if(sdci[5]!=0) //rotation
1092 {
1093 int32_t xy[2];
1094 int32_t rx=sdci[3]/10000;
1095 int32_t ry=sdci[4]/10000;
1096 fixed ra1=itofix(sdci[5]%10000)/10000;
1097 fixed ra2=itofix(sdci[5]/10000);
1098 fixed ra=ra1+ra2;
1099
1100 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1101 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1102 x1=xy[0];
1103 y1=xy[1];
1104 }
1105 if ( v.at(q+3) /*pos[q+3]*/ < 128 ) drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1106 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1107 putpixel(bmp, x1+xoffset, y1+yoffset, v.at(q+2) /*pos[q+2]*/);
1108 }
1109 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1110 }
1111
1112 2302534 void do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1113 {
1114 //sdci[1]=layer
1115 //sdci[2]=x
1116 //sdci[3]=y
1117 //sdci[4]=tile
1118 //sdci[5]=tile width
1119 //sdci[6]=tile height
1120 //sdci[7]=color (cset)
1121 //sdci[8]=scale x
1122 //sdci[9]=scale y
1123 //sdci[10]=rotation anchor x
1124 //sdci[11]=rotation anchor y
1125 //sdci[12]=rotation angle
1126 //sdci[13]=flip
1127 //sdci[14]=transparency
1128 //sdci[15]=opacity
1129
1130 2302534 int32_t w = sdci[5]/10000;
1131 2302534 int32_t h = sdci[6]/10000;
1132
1133
4/8
✓ Branch 0 taken 2302534 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2302534 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2302534 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2302534 times.
2302534 if(w < 1 || h < 1 || h > 20 || w > 20)
1134 {
1135 return;
1136 }
1137
1138 2302534 int32_t xscale=sdci[8]/10000;
1139 2302534 int32_t yscale=sdci[9]/10000;
1140 2302534 int32_t rx = sdci[10]/10000;
1141 2302534 int32_t ry = sdci[11]/10000;
1142 2302534 float rotation=sdci[12]/10000;
1143 2302534 int32_t flip=(sdci[13]/10000)&3;
1144 2302534 bool transparency=sdci[14]!=0;
1145 2302534 int32_t opacity=sdci[15]/10000;
1146 2302534 int32_t color=sdci[7]/10000;
1147
1148 2302534 int32_t x1=sdci[2]/10000;
1149 2302534 int32_t y1=sdci[3]/10000;
1150
1/2
✓ Branch 0 taken 2302534 times.
✗ Branch 1 not taken.
2302534 byte skiprows = get_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY) ? 0 : h-1;
1151
1152 //don't scale if it's not safe to do so
1153 2302534 bool canscale = true;
1154
1155
3/4
✓ Branch 0 taken 2281889 times.
✓ Branch 1 taken 20645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2281889 times.
2302534 if(xscale==0||yscale==0)
1156 {
1157 20645 return;
1158 }
1159
1160
3/4
✓ Branch 0 taken 141060 times.
✓ Branch 1 taken 2140829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 141060 times.
2281889 if(xscale<=0||yscale<=0)
1161 2140829 canscale = false; //default size
1162
1163
4/4
✓ Branch 0 taken 141060 times.
✓ Branch 1 taken 2140829 times.
✓ Branch 2 taken 140626 times.
✓ Branch 3 taken 2000203 times.
2281889 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1164 {
1165 281686 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
1166
1167
1/2
✓ Branch 0 taken 281686 times.
✗ Branch 1 not taken.
281686 if(transparency) //transparency
1168 {
1169 281686 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip, skiprows);
1170 281686 }
1171 else //no transparency
1172 {
1173 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip, skiprows);
1174 }
1175
1176
2/2
✓ Branch 0 taken 144314 times.
✓ Branch 1 taken 137372 times.
281686 if(rotation != 0)
1177 {
1178 //low negative values indicate no anchor-point rotation
1179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144314 if(rx>-777||ry>-777)
1180 {
1181 int32_t xy[2];
1182 144314 fixed ra1=itofix(sdci[12]%10000)/10000;
1183 144314 fixed ra2=itofix(sdci[12]/10000);
1184 144314 fixed ra=ra1+ra2;
1185 144314 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1186 144314 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1187 144314 x1=xy[0];
1188 144314 y1=xy[1];
1189 144314 }
1190
1191
2/2
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 140626 times.
144314 if(canscale) //scale first
1192 {
1193 //damnit all, .. fixme.
1194
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3688 times.
3688 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1195 3688 clear_bitmap(tempbit);
1196
1197 3688 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1198
1199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
3688 if(opacity < 128)
1200 {
1201 clear_bitmap(prim_bmp);
1202 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1203 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1204 }
1205 else
1206 {
1207 3688 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1208 }
1209
1210 3688 destroy_bitmap(tempbit);
1211 3688 }
1212 else //no scale
1213 {
1214
2/2
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 137040 times.
140626 if(opacity < 128)
1215 {
1216 3586 clear_bitmap(prim_bmp);
1217 3586 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1218 3586 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1219 3586 }
1220 else
1221 {
1222 137040 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1223 }
1224 }
1225 144314 }
1226 else //scale only
1227 {
1228
1/2
✓ Branch 0 taken 137372 times.
✗ Branch 1 not taken.
137372 if(canscale)
1229 {
1230
2/2
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 133028 times.
137372 if(opacity<128)
1231 {
1232 4344 clear_bitmap(prim_bmp);
1233 4344 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1234 4344 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1235 4344 }
1236 else
1237 {
1238 133028 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1239 }
1240 137372 }
1241 else //error -do not scale
1242 {
1243 if(opacity<128)
1244 {
1245 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1246 }
1247 else
1248 {
1249 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1250 }
1251 }
1252 }
1253
1254 281686 script_drawing_commands.ReleaseSubBitmap(pbitty);
1255
1256 281686 }
1257 else // no scale or rotation
1258 {
1259
2/2
✓ Branch 0 taken 1972749 times.
✓ Branch 1 taken 27454 times.
2000203 if(transparency)
1260 {
1261
2/2
✓ Branch 0 taken 224767 times.
✓ Branch 1 taken 1747982 times.
1972749 if(opacity<=127)
1262 224767 TileHelper::OverTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1263 else
1264 1747982 TileHelper::OverTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1265 1972749 }
1266 else
1267 {
1268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27454 times.
27454 if(opacity<=127)
1269 TileHelper::PutTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1270 else
1271 27454 TileHelper::OldPutTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1272 }
1273 }
1274 2302534 }
1275
1276 void do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1277 {
1278 //sdci[1]=layer
1279 //sdci[2]=x
1280 //sdci[3]=y
1281 //sdci[4]=tile
1282 //sdci[5]=tile width
1283 //sdci[6]=tile height
1284 //sdci[7]=flip
1285
1286 int32_t w = sdci[5]/10000;
1287 int32_t h = sdci[6]/10000;
1288
1289 if(w < 1 || h < 1 || h > 20 || w > 20)
1290 {
1291 return;
1292 }
1293
1294 int32_t flip=(sdci[7]/10000)&3;
1295
1296 int32_t x1=sdci[2]/10000;
1297 int32_t y1=sdci[3]/10000;
1298 byte skiprows = get_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY) ? 0 : h-1;
1299
1300 TileHelper::OverTileCloaked(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip, skiprows);
1301 }
1302
1303
1304 2761920 void do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1305 {
1306 //sdci[1]=layer
1307 //sdci[2]=x
1308 //sdci[3]=y
1309 //sdci[4]=combo
1310 //sdci[5]=tile width
1311 //sdci[6]=tile height
1312 //sdci[7]=color (cset)
1313 //sdci[8]=scale x
1314 //sdci[9]=scale y
1315 //sdci[10]=rotation anchor x
1316 //sdci[11]=rotation anchor y
1317 //sdci[12]=rotation angle
1318 //sdci[13]=frame
1319 //sdci[14]=flip
1320 //sdci[15]=transparency
1321 //sdci[16]=opacity
1322
1323 2761920 int32_t w = sdci[5]/10000;
1324 2761920 int32_t h = sdci[6]/10000;
1325
1326
4/8
✓ Branch 0 taken 2761920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2761920 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2761920 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2761920 times.
2761920 if(w<1||h<1||h>20||w>20)
1327 {
1328 return;
1329 }
1330 2761920 int32_t cmb = (sdci[4]/10000);
1331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761920 times.
2761920 if((unsigned)cmb >= MAXCOMBOS)
1332 {
1333 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1334 return;
1335 }
1336
1337 2761920 int32_t xscale=sdci[8]/10000;
1338 2761920 int32_t yscale=sdci[9]/10000;
1339 2761920 int32_t rx = sdci[10]/10000; //these work now
1340 2761920 int32_t ry = sdci[11]/10000; //these work now
1341 2761920 float rotation=sdci[12]/10000;
1342
1343 2761920 bool transparency=sdci[15]!=0;
1344 2761920 int32_t opacity=sdci[16]/10000;
1345 2761920 int32_t color=sdci[7]/10000;
1346 2761920 int32_t x1=sdci[2]/10000;
1347 2761920 int32_t y1=sdci[3]/10000;
1348
1349 2761920 auto& c = GET_DRAWING_COMBO(cmb);
1350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761920 times.
2761920 if(c.animflags & AF_EDITOR_ONLY) return;
1351 2761920 int frame = sdci[13] / 10000;
1352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761920 times.
2761920 if (get_qr(qr_DRAWCOMBO_IGNORES_FRAME))
1353 2761920 frame = -1;
1354 2761920 int32_t tiletodraw = combo_tile(c, x1, y1, frame);
1355 2761920 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
1356 2761920 int32_t skiprows=c.skipanimy;
1357
1358
1359 //don't scale if it's not safe to do so
1360 2761920 bool canscale = true;
1361
1362
3/4
✓ Branch 0 taken 2761847 times.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2761847 times.
2761920 if(xscale==0||yscale==0)
1363 {
1364 73 return;
1365 }
1366
1367
3/4
✓ Branch 0 taken 23422 times.
✓ Branch 1 taken 2738425 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23422 times.
2761847 if(xscale<=0||yscale<=0)
1368 2738425 canscale = false; //default size
1369
1370
4/4
✓ Branch 0 taken 23422 times.
✓ Branch 1 taken 2738425 times.
✓ Branch 2 taken 109319 times.
✓ Branch 3 taken 2629106 times.
2761847 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1371 {
1372 132741 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
1373
1374
2/2
✓ Branch 0 taken 131705 times.
✓ Branch 1 taken 1036 times.
132741 if(transparency)
1375 {
1376 131705 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1377 131705 }
1378 else //no transparency
1379 {
1380 1036 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1381 }
1382
1383
2/2
✓ Branch 0 taken 109537 times.
✓ Branch 1 taken 23204 times.
132741 if(rotation != 0) // rotate
1384 {
1385 //fixed point sucks ;0
1386
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 109537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
109537 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
1387 {
1388 int32_t xy[2];
1389 109537 fixed ra1=itofix(sdci[12]%10000)/10000;
1390 109537 fixed ra2=itofix(sdci[12]/10000);
1391 109537 fixed ra=ra1+ra2;
1392 109537 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1393 109537 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1394 109537 x1=xy[0];
1395 109537 y1=xy[1];
1396 109537 }
1397
1398
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109319 times.
109537 if(canscale) //scale first
1399 {
1400
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 218 times.
218 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1401 218 clear_bitmap(tempbit);
1402
1403 218 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1404
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if(opacity < 128)
1406 {
1407 clear_bitmap(prim_bmp);
1408 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1409 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1410 }
1411 else
1412 {
1413 218 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1414 }
1415
1416 218 destroy_bitmap(tempbit);
1417 218 }
1418 else //no scale
1419 {
1420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109319 times.
109319 if(opacity < 128)
1421 {
1422 clear_bitmap(prim_bmp);
1423 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1424 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1425 }
1426 else
1427 {
1428 109319 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1429 }
1430 }
1431 109537 }
1432 else //scale only
1433 {
1434
1/2
✓ Branch 0 taken 23204 times.
✗ Branch 1 not taken.
23204 if(canscale)
1435 {
1436
2/2
✓ Branch 0 taken 9395 times.
✓ Branch 1 taken 13809 times.
23204 if(opacity<128)
1437 {
1438 9395 clear_bitmap(prim_bmp);
1439 9395 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1440 9395 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1441 9395 }
1442 else
1443 {
1444 13809 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1445 }
1446 23204 }
1447 else //error -do not scale
1448 {
1449 if(opacity<128)
1450 {
1451 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1452 }
1453 else
1454 {
1455 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1456 }
1457 }
1458 }
1459
1460 132741 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
1461 132741 }
1462 else // no scale or rotation
1463 {
1464
1/2
✓ Branch 0 taken 2629106 times.
✗ Branch 1 not taken.
2629106 if(transparency)
1465 {
1466
2/2
✓ Branch 0 taken 64341 times.
✓ Branch 1 taken 2564765 times.
2629106 if(opacity<=127)
1467 64341 TileHelper::OverTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1468 else
1469 2564765 TileHelper::OverTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1470 2629106 }
1471 else
1472 {
1473 if(opacity<=127)
1474 TileHelper::PutTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1475 else
1476 TileHelper::OldPutTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1477 }
1478 }
1479 2761920 }
1480
1481 void do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1482 {
1483 //sdci[1]=layer
1484 //sdci[2]=x
1485 //sdci[3]=y
1486 //sdci[4]=combo
1487 //sdci[5]=tile width
1488 //sdci[6]=tile height
1489 //sdci[7]=flip
1490
1491 int32_t w = sdci[5]/10000;
1492 int32_t h = sdci[6]/10000;
1493
1494 if(w<1||h<1||h>20||w>20)
1495 {
1496 return;
1497 }
1498 int32_t cmb = (sdci[4]/10000);
1499 if((unsigned)cmb >= MAXCOMBOS)
1500 {
1501 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1502 return;
1503 }
1504
1505 int32_t x1=sdci[2]/10000;
1506 int32_t y1=sdci[3]/10000;
1507
1508 auto& c = GET_DRAWING_COMBO(cmb);
1509 int32_t tiletodraw = combo_tile(c, x1, y1);
1510 if(c.animflags & AF_EDITOR_ONLY) return;
1511 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
1512 int32_t skiprows=c.skipanimy;
1513
1514 TileHelper::OverTileCloaked(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
1515 }
1516
1517
1518 5327982 void do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1519 {
1520 /* layer, x, y, tile, color opacity */
1521
1522 5327982 int32_t opacity = sdci[6]/10000;
1523 5327982 int x = xoffset+(sdci[2]/10000);
1524 5327982 int y = yoffset+(sdci[3]/10000);
1525
1526
2/2
✓ Branch 0 taken 154230 times.
✓ Branch 1 taken 5173752 times.
5327982 if(opacity < 128)
1527 154230 overtiletranslucent16(bmp, sdci[4]/10000, x, y, sdci[5]/10000, 0, opacity);
1528 else
1529 5173752 overtile16(bmp, sdci[4]/10000, x, y, sdci[5]/10000, 0);
1530 5327982 }
1531
1532 void do_fasttilesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1533 {
1534 /* layer, x, y, tile, color opacity */
1535
1536 //sdci[1]=layer
1537 //sdci[2]=array {x,y,tile,colour,opacity}
1538
1539 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1540
1541 if(!v_ptr)
1542 {
1543 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1544 return;
1545 }
1546
1547 std::vector<int32_t> &v = *v_ptr;
1548
1549 if(v.empty())
1550 return;
1551
1552 int32_t* pos = &v[0];
1553 int32_t sz = v.size();
1554
1555 for ( int32_t q = 0; q < sz; q+=5 )
1556 {
1557
1558 if(v.at(q+4) < 128)
1559 overtiletranslucent16(bmp, v.at(q+2), xoffset+(v.at(q)), yoffset+(v.at(q+1)), v.at(q+3), 0, v.at(q+4));
1560 else
1561 overtile16(bmp, v.at(q+2), xoffset+(v.at(q)), yoffset+(v.at(q+1)), v.at(q+3), 0);
1562 }
1563 }
1564
1565
1566
1567 30256034 void do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1568 {
1569 /* layer, x, y, tile, color opacity */
1570
1571 30256034 int32_t opacity = sdci[6] / 10000;
1572 30256034 int32_t x1 = sdci[2] / 10000;
1573 30256034 int32_t y1 = sdci[3] / 10000;
1574
1575 30256034 int32_t cmb = (sdci[4]/10000);
1576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30256034 times.
30256034 if((unsigned)cmb >= MAXCOMBOS)
1577 {
1578 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1579 return;
1580 }
1581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30256034 times.
30256034 if(combobuf[cmb].animflags & AF_EDITOR_ONLY) return;
1582
1583 30256034 int x = xoffset+x1;
1584 30256034 int y = yoffset+y1;
1585
1586
2/2
✓ Branch 0 taken 7829244 times.
✓ Branch 1 taken 22426790 times.
30256034 if(opacity < 128)
1587 {
1588 7829244 overcomboblocktranslucent(bmp, x, y, cmb, sdci[5]/10000, 1, 1, 128);
1589 7829244 }
1590 else
1591 {
1592 22426790 overcomboblock(bmp, x, y, cmb, sdci[5]/10000, 1, 1);
1593 }
1594 30256034 }
1595
1596 void do_fastcombosr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1597 {
1598 /* layer, x, y, combo, cset, opacity */
1599 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1600
1601 if(!v_ptr)
1602 {
1603 al_trace("Screen->FastCombos: Vector pointer is null! Internal error. \n");
1604 return;
1605 }
1606
1607 std::vector<int32_t> &v = *v_ptr;
1608
1609 if(v.empty())
1610 return;
1611
1612 int32_t* pos = &v[0];
1613 int32_t sz = v.size();
1614
1615 for ( int32_t q = 0; q < sz; q+=5 )
1616 {
1617 auto cid = v.at(q+2);
1618 if((unsigned)(cid) >= MAXCOMBOS)
1619 {
1620 Z_scripterrlog("FastCombos() cannot draw combo '%d', as it is out of bounds.\n", v.at(q+2));
1621 continue;
1622 }
1623 if(combobuf[cid].animflags & AF_EDITOR_ONLY) continue;
1624 if(v.at(q+4) < 128)
1625 {
1626 overcomboblocktranslucent(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1, 128);
1627
1628 }
1629 else
1630 {
1631 overcomboblock(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1);
1632 }
1633 }
1634 }
1635
1636
1637
1638
1639 964155 void do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1640 {
1641 //broken 2.50.2 and earlier drawcharacter()
1642
2/2
✓ Branch 0 taken 18543 times.
✓ Branch 1 taken 945612 times.
964155 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1643 {
1644 //sdci[1]=layer
1645 //sdci[2]=x
1646 //sdci[3]=y
1647 //sdci[4]=font
1648 //sdci[5]=color
1649 //sdci[6]=bg color
1650 //sdci[7]=strech x (width)
1651 //sdci[8]=stretch y (height)
1652 //sdci[9]=char
1653 //sdci[10]=opacity
1654
1655 18543 int32_t x=sdci[2]/10000;
1656 18543 int32_t y=sdci[3]/10000;
1657 18543 int32_t font_index=sdci[4]/10000;
1658 18543 int32_t color=sdci[5]/10000;
1659 18543 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1660 18543 int32_t w=sdci[7]/10000;
1661 18543 int32_t h=sdci[8]/10000;
1662 18543 char glyph=char(sdci[9]/10000);
1663 18543 int32_t opacity=sdci[10]/10000;
1664
1665 //safe check
1666
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(bg_color < -1) bg_color = -1;
1667
1668
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(w>512) w=512; //w=vbound(w,0,512);
1669
1670
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(h>512) h=512; //h=vbound(h,0,512);
1671
1672 //undone
1673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18543 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18543 if(w>0&&h>0)//stretch the character
1674 {
1675 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1676
1677 if(opacity < 128)
1678 {
1679 if(w>128||h>128)
1680 {
1681 clear_bitmap(prim_bmp);
1682
1683 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1684 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1685 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1686 }
1687 else //this is faster
1688 {
1689 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1690
1691 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1692 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1693 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1694
1695 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1696 }
1697 }
1698 else // no opacity
1699 {
1700 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1701 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1702 }
1703
1704 }
1705 else //no stretch
1706 {
1707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18543 times.
18543 if(opacity < 128)
1708 {
1709 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1710 clear_bitmap(pbmp);
1711
1712 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1713 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1714
1715 destroy_bitmap(pbmp);
1716 }
1717 else // no opacity
1718 {
1719 18543 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1720 }
1721 }
1722 18543 }
1723
1724 else //2.53.0 fixed version and later.
1725 {
1726
1727 //sdci[1]=layer
1728 //sdci[2]=x
1729 //sdci[3]=y
1730 //sdci[4]=font
1731 //sdci[5]=color
1732 //sdci[6]=bg color
1733 //sdci[7]=strech x (width)
1734 //sdci[8]=stretch y (height)
1735 //sdci[9]=char
1736 //sdci[10]=opacity
1737
1738 945612 int32_t x=sdci[2]/10000;
1739 945612 int32_t y=sdci[3]/10000;
1740 945612 int32_t font_index=sdci[4]/10000;
1741 945612 int32_t color=sdci[5]/10000;
1742 945612 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1743 945612 int32_t w=sdci[7]/10000;
1744 945612 int32_t h=sdci[8]/10000;
1745 945612 char glyph=char(sdci[9]/10000);
1746 945612 int32_t opacity=sdci[10]/10000;
1747
1748 //safe check
1749
1/2
✓ Branch 0 taken 945612 times.
✗ Branch 1 not taken.
945612 if(bg_color < -1) bg_color = -1;
1750
1751
1/2
✓ Branch 0 taken 945612 times.
✗ Branch 1 not taken.
945612 if(w>512) w=512; //w=vbound(w,0,512);
1752
1753
1/2
✓ Branch 0 taken 945612 times.
✗ Branch 1 not taken.
945612 if(h>512) h=512; //h=vbound(h,0,512);
1754
1755 //undone
1756
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 945612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
945612 if(w>0&&h>0)//stretch the character
1757 {
1758 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1759
1760 if(opacity < 128)
1761 {
1762 if(w>128||h>128)
1763 {
1764 clear_bitmap(prim_bmp);
1765
1766 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1767 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1768 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1769 }
1770 else //this is faster
1771 {
1772 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1773
1774 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1775 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1776 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1777
1778 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1779 }
1780 }
1781 else // no opacity
1782 {
1783 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1784 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1785 }
1786
1787 }
1788 else //no stretch
1789 {
1790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945612 times.
945612 if(opacity < 128)
1791 {
1792 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1793 clear_bitmap(pbmp);
1794
1795 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1796 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1797
1798 destroy_bitmap(pbmp);
1799 }
1800 else // no opacity
1801 {
1802 945612 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1803 }
1804 }
1805
1806 }
1807
1808 964155 }
1809
1810
1811 176452 void do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1812 {
1813 //broken 2.50.2 and earlier drawinteger()
1814
2/2
✓ Branch 0 taken 72655 times.
✓ Branch 1 taken 103797 times.
176452 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1815 {
1816 //sdci[1]=layer
1817 //sdci[2]=x
1818 //sdci[3]=y
1819 //sdci[4]=font
1820 //sdci[5]=color
1821 //sdci[6]=bg color
1822 //sdci[7]=strech x (width)
1823 //sdci[8]=stretch y (height)
1824 //sdci[9]=integer
1825 //sdci[10]=num decimal places
1826 //sdci[11]=opacity
1827
1828 72655 int32_t x=sdci[2]/10000;
1829 72655 int32_t y=sdci[3]/10000;
1830 72655 int32_t font_index=sdci[4]/10000;
1831 72655 int32_t color=sdci[5]/10000;
1832 72655 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1833 72655 int32_t w=sdci[7]/10000;
1834 72655 int32_t h=sdci[8]/10000;
1835 72655 int32_t decplace=sdci[10]/10000;
1836 72655 int32_t opacity=sdci[11]/10000;
1837
1838 //safe check
1839
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(bg_color < -1) bg_color = -1;
1840
1841
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(w>512) w=512; //w=vbound(w,0,512);
1842
1843
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(h>512) h=512; //h=vbound(h,0,512);
1844
1845 char numbuf[15];
1846
1847
1/6
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
72655 switch(decplace)
1848 {
1849 default:
1850 case 0:
1851 72655 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1852 72655 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1853
1854 case 1:
1855 //sprintf(numbuf,"%.01f",number);
1856 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1857 break;
1858
1859 case 2:
1860 //sprintf(numbuf,"%.02f",number);
1861 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1862 break;
1863
1864 case 3:
1865 //sprintf(numbuf,"%.03f",number);
1866 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1867 break;
1868
1869 case 4:
1870 //sprintf(numbuf,"%.04f",number);
1871 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1872 break;
1873 }
1874
1875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72655 if(w>0&&h>0)//stretch
1876 {
1877 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1878
1879 if(opacity < 128)
1880 {
1881 if(w>128||h>128)
1882 {
1883 clear_bitmap(prim_bmp);
1884
1885 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1886 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1887 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1888 }
1889 else
1890 {
1891 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
1892 clear_bitmap(pbmp2);
1893
1894 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1895 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1896 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1897
1898 destroy_bitmap(pbmp2);
1899 }
1900 }
1901 else // no opacity
1902 {
1903 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1904 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1905 }
1906
1907 }
1908 else //no stretch
1909 {
1910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72655 times.
72655 if(opacity < 128)
1911 {
1912 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1913 clear_bitmap(pbmp);
1914
1915 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1916 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1917
1918 destroy_bitmap(pbmp);
1919 }
1920 else // no opacity
1921 {
1922 72655 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
1923 }
1924 }
1925
1926 72655 }
1927
1928 else //2.53.0 fixed version and later.
1929 {
1930 //sdci[1]=layer
1931 //sdci[2]=x
1932 //sdci[3]=y
1933 //sdci[4]=font
1934 //sdci[5]=color
1935 //sdci[6]=bg color
1936 //sdci[7]=strech x (width)
1937 //sdci[8]=stretch y (height)
1938 //sdci[9]=integer
1939 //sdci[10]=num decimal places
1940 //sdci[11]=opacity
1941
1942 103797 int32_t x=sdci[2]/10000;
1943 103797 int32_t y=sdci[3]/10000;
1944 103797 int32_t font_index=sdci[4]/10000;
1945 103797 int32_t color=sdci[5]/10000;
1946 103797 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1947 103797 int32_t w=sdci[7]/10000;
1948 103797 int32_t h=sdci[8]/10000;
1949 103797 int32_t decplace=sdci[10]/10000;
1950 103797 int32_t opacity=sdci[11]/10000;
1951
1952 //safe check
1953
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(bg_color < -1) bg_color = -1;
1954
1955
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(w>512) w=512; //w=vbound(w,0,512);
1956
1957
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(h>512) h=512; //h=vbound(h,0,512);
1958
1959 char numbuf[15];
1960
1961
1/6
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
103797 switch(decplace)
1962 {
1963 default:
1964 case 0:
1965 103797 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1966 103797 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1967
1968 case 1:
1969 //sprintf(numbuf,"%.01f",number);
1970 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1971 break;
1972
1973 case 2:
1974 //sprintf(numbuf,"%.02f",number);
1975 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1976 break;
1977
1978 case 3:
1979 //sprintf(numbuf,"%.03f",number);
1980 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1981 break;
1982
1983 case 4:
1984 //sprintf(numbuf,"%.04f",number);
1985 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1986 break;
1987 }
1988
1989 //FONT* font=get_zc_font(sdci[4]/10000);
1990
1991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 103797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
103797 if(w>0&&h>0)//stretch
1992 {
1993 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
1994 clear_bitmap(pbmp);
1995 //script_drawing_commands.GetSmallTextureBitmap(1,1);
1996
1997 if(opacity < 128)
1998 {
1999 if(w>128||h>128)
2000 {
2001 clear_bitmap(prim_bmp);
2002
2003 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2004 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
2005 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
2006 }
2007 else
2008 {
2009 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
2010 clear_bitmap(pbmp2);
2011
2012 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2013 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
2014 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
2015
2016 destroy_bitmap(pbmp2);
2017 }
2018 }
2019 else // no opacity
2020 {
2021 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2022 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
2023 }
2024
2025 }
2026 else //no stretch
2027 {
2028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103797 times.
103797 if(opacity < 128)
2029 {
2030 FONT* font = get_zc_font(font_index);
2031 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
2032 clear_bitmap(pbmp);
2033
2034 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
2035 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2036
2037 destroy_bitmap(pbmp);
2038 }
2039 else // no opacity
2040 {
2041 103797 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
2042 }
2043 }
2044 }
2045 176452 }
2046
2047
2048 1607511 void do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2049 {
2050 //sdci[1]=layer
2051 //sdci[2]=x
2052 //sdci[3]=y
2053 //sdci[4]=font
2054 //sdci[5]=color
2055 //sdci[6]=bg color
2056 //sdci[7]=format_option
2057 //sdci[8]=string
2058 //sdci[9]=opacity
2059
2060 1607511 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2061
2062
1/2
✓ Branch 0 taken 1607511 times.
✗ Branch 1 not taken.
1607511 if(!str)
2063 {
2064 al_trace("String pointer is null! Internal error. \n");
2065 return;
2066 }
2067
2068 1607511 int32_t x=sdci[2]/10000;
2069 1607511 int32_t y=sdci[3]/10000;
2070 1607511 FONT* font=get_zc_font(sdci[4]/10000);
2071 1607511 int32_t color=sdci[5]/10000;
2072 1607511 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2073 1607511 int32_t format_type=sdci[7]/10000;
2074 1607511 int32_t opacity=sdci[9]/10000;
2075 //sdci[8] not needed :)
2076
2077 //safe check
2078
1/2
✓ Branch 0 taken 1607511 times.
✗ Branch 1 not taken.
1607511 if(bg_color < -1) bg_color = -1;
2079
2080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1607511 times.
1607511 if(opacity < 128)
2081 {
2082 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2083 if (width < 1) return; //SANITY -Em
2084 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2085 clear_bitmap(pbmp);
2086 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2087 if(format_type == 2) // right-sided text
2088 x-=width;
2089 else if(format_type == 1) // centered text
2090 x-=width/2;
2091 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2092 destroy_bitmap(pbmp);
2093 }
2094 else // no opacity
2095 {
2096
2/2
✓ Branch 0 taken 14345 times.
✓ Branch 1 taken 1593166 times.
1607511 if(format_type == 2) // right-sided text
2097 {
2098 14345 textout_right_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2099 14345 }
2100
2/2
✓ Branch 0 taken 725712 times.
✓ Branch 1 taken 867454 times.
1593166 else if(format_type == 1) // centered text
2101 {
2102 725712 textout_centre_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2103 725712 }
2104 else // standard left-sided text
2105 {
2106 867454 textout_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2107 }
2108 }
2109 1607511 }
2110
2111 201739 void do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2112 {
2113 //sdci[1]=layer
2114 //sdci[2]=x
2115 //sdci[3]=y
2116 //sdci[4]=font
2117 //sdci[5]=color
2118 //sdci[6]=bg color
2119 //sdci[7]=format_option
2120 //sdci[8]=string
2121 //sdci[9]=opacity
2122 //sdci[10]=shadowtype
2123 //sdci[11]=shadow_color
2124
2125 201739 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2126
2127
1/2
✓ Branch 0 taken 201739 times.
✗ Branch 1 not taken.
201739 if(!str)
2128 {
2129 al_trace("String pointer is null! Internal error. \n");
2130 return;
2131 }
2132
2133 201739 int32_t x=sdci[2]/10000;
2134 201739 int32_t y=sdci[3]/10000;
2135 201739 FONT* font=get_zc_font(sdci[4]/10000);
2136 201739 int32_t color=sdci[5]/10000;
2137 201739 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2138 201739 int32_t format_type=sdci[7]/10000;
2139 201739 int32_t opacity=sdci[9]/10000;
2140 201739 int32_t textstyle = sdci[10]/10000;
2141 201739 int32_t shadow_color = sdci[11]/10000;
2142 //sdci[8] not needed :)
2143
2144 //safe check
2145
1/2
✓ Branch 0 taken 201739 times.
✗ Branch 1 not taken.
201739 if(bg_color < -1) bg_color = -1;
2146
2147
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 200999 times.
201739 if(opacity < 128)
2148 {
2149
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2150
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if (width < 1) return; //SANITY -Em
2151 740 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2152 740 clear_bitmap(pbmp);
2153 740 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, ALIGN_LEFT, color, shadow_color, bg_color);
2154 740 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
740 if(format_type == 2) // right-sided text
2156 x-=width;
2157
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 else if(format_type == 1) // centered text
2158 740 x-=width/2;
2159 740 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2160 740 destroy_bitmap(pbmp);
2161 740 }
2162 else // no opacity
2163 {
2164 200999 textout_styled_aligned_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
2165 }
2166 201739 }
2167
2168
2169 9266 void do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2170 {
2171 //sdci[1]=layer
2172 //sdci[2]=x1
2173 //sdci[3]=y1
2174 //sdci[4]=x2
2175 //sdci[5]=y2
2176 //sdci[6]=x3
2177 //sdci[7]=y3
2178 //sdci[8]=x4
2179 //sdci[9]=y4
2180 //sdci[10]=width
2181 //sdci[11]=height
2182 //sdci[12]=cset
2183 //sdci[13]=flip
2184 //sdci[14]=tile/combo
2185 //sdci[15]=polytype
2186
2187 9266 int32_t x1 = sdci[2]/10000;
2188 9266 int32_t y1 = sdci[3]/10000;
2189 9266 int32_t x2 = sdci[4]/10000;
2190 9266 int32_t y2 = sdci[5]/10000;
2191 9266 int32_t x3 = sdci[6]/10000;
2192 9266 int32_t y3 = sdci[7]/10000;
2193 9266 int32_t x4 = sdci[8]/10000;
2194 9266 int32_t y4 = sdci[9]/10000;
2195 9266 int32_t w = sdci[10]/10000;
2196 9266 int32_t h = sdci[11]/10000;
2197 9266 int32_t color = sdci[12]/10000;
2198 9266 int32_t flip=(sdci[13]/10000)&3;
2199 9266 int32_t tile = sdci[14]/10000;
2200 9266 int32_t polytype = sdci[15]/10000;
2201
2202 //todo: finish palette shading
2203 /*
2204 POLYTYPE_FLAT
2205 POLYTYPE_GCOL
2206 POLYTYPE_GRGB
2207 POLYTYPE_ATEX
2208 POLYTYPE_PTEX
2209 POLYTYPE_ATEX_MASK
2210 POLYTYPE_PTEX_MASK
2211 POLYTYPE_ATEX_LIT
2212 POLYTYPE_PTEX_LIT
2213 POLYTYPE_ATEX_MASK_LIT
2214 POLYTYPE_PTEX_MASK_LIT
2215 POLYTYPE_ATEX_TRANS
2216 POLYTYPE_PTEX_TRANS
2217 POLYTYPE_ATEX_MASK_TRANS
2218 POLYTYPE_PTEX_MASK_TRANS
2219 */
2220 9266 polytype = vbound(polytype, 0, 14);
2221
2222
2/4
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9266 times.
✗ Branch 3 not taken.
9266 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2223 {
2224 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2225 return; //non power of two error
2226 }
2227
2228 9266 int32_t tex_width = w*16;
2229 9266 int32_t tex_height = h*16;
2230
2231 BITMAP *tex;
2232
2233 9266 bool mustDestroyBmp = false;
2234
2235 9266 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2236
2237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if(!tex)
2238 {
2239 mustDestroyBmp = true;
2240 tex = create_bitmap_ex(8, tex_width, tex_height);
2241 clear_bitmap(tex);
2242 }
2243
2244 int32_t col[4];
2245 /*
2246 if( color < 0 )
2247 {
2248 col[0]=draw_container.color_buffer[0];
2249 col[1]=draw_container.color_buffer[1];
2250 col[2]=draw_container.color_buffer[2];
2251 col[3]=draw_container.color_buffer[3];
2252 }
2253 else */
2254 {
2255 9266 col[0]=col[1]=col[2]=col[3]=color;
2256 }
2257
2258
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if (tile > 0) // TILE
2259 {
2260 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2261 }
2262
2263
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if ( tile < 0 ) // COMBO
2264 {
2265 9266 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
2266 9266 const int32_t tiletodraw = combo_tile(c, x1, y1);
2267 9266 flip = flip ^ c.flip;
2268
2269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if(!(c.animflags & AF_EDITOR_ONLY))
2270 9266 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2271 9266 }
2272
2273 9266 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2274 9266 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2275 9266 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2276 9266 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(tex_width), 0, col[3] };
2277
2278 9266 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
2279
2280
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if(mustDestroyBmp)
2281 destroy_bitmap(tex);
2282
2283 9266 }
2284
2285
2286 void do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2287 {
2288 //sdci[1]=layer
2289 //sdci[2]=x1
2290 //sdci[3]=y1
2291 //sdci[4]=x2
2292 //sdci[5]=y2
2293 //sdci[6]=x3
2294 //sdci[7]=y3
2295 //sdci[8]=width
2296 //sdci[9]=height
2297 //sdci[10]=cset
2298 //sdci[11]=flip
2299 //sdci[12]=tile/combo
2300 //sdci[13]=polytype
2301
2302 int32_t x1 = sdci[2]/10000;
2303 int32_t y1 = sdci[3]/10000;
2304 int32_t x2 = sdci[4]/10000;
2305 int32_t y2 = sdci[5]/10000;
2306 int32_t x3 = sdci[6]/10000;
2307 int32_t y3 = sdci[7]/10000;
2308 int32_t w = sdci[8]/10000;
2309 int32_t h = sdci[9]/10000;
2310 int32_t color = sdci[10]/10000;
2311 int32_t flip=(sdci[11]/10000)&3;
2312 int32_t tile = sdci[12]/10000;
2313 int32_t polytype = sdci[13]/10000;
2314
2315 polytype = vbound(polytype, 0, 14);
2316
2317 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2318 {
2319 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2320 return; //non power of two error
2321 }
2322
2323 int32_t tex_width = w*16;
2324 int32_t tex_height = h*16;
2325
2326 bool mustDestroyBmp = false;
2327 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2328
2329 if(!tex)
2330 {
2331 mustDestroyBmp = true;
2332 tex = create_bitmap_ex(8, tex_width, tex_height);
2333 clear_bitmap(tex);
2334 }
2335
2336 int32_t col[3];
2337 /*
2338 if( color < 0 )
2339 {
2340 col[0]=draw_container.color_buffer[0];
2341 col[1]=draw_container.color_buffer[1];
2342 col[2]=draw_container.color_buffer[2];
2343 }
2344 else */
2345 {
2346 col[0]=col[1]=col[2]=color;
2347 }
2348
2349 if(tile > 0) // TILE
2350 {
2351 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2352 }
2353 else // COMBO
2354 {
2355 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
2356 const int32_t tiletodraw = combo_tile(c, x1, y1);
2357 flip = flip ^ c.flip;
2358
2359 if(!(c.animflags & AF_EDITOR_ONLY))
2360 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2361 }
2362
2363 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2364 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2365 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2366
2367
2368 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
2369
2370 if(mustDestroyBmp)
2371 destroy_bitmap(tex);
2372 }
2373
2374
2375 937483 void do_drawbitmapr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2376 {
2377 //sdci[1]=layer
2378 //sdci[2]=bitmap
2379 //sdci[3]=sourcex
2380 //sdci[4]=sourcey
2381 //sdci[5]=sourcew
2382 //sdci[6]=sourceh
2383 //sdci[7]=destx
2384 //sdci[8]=desty
2385 //sdci[9]=destw
2386 //sdci[10]=desth
2387 //sdci[11]=rotation
2388 //sdci[12]=mask
2389
2390 937483 int32_t bitmapIndex = sdci[2]/10000;
2391 937483 int32_t sx = sdci[3]/10000;
2392 937483 int32_t sy = sdci[4]/10000;
2393 937483 int32_t sw = sdci[5]/10000;
2394 937483 int32_t sh = sdci[6]/10000;
2395 937483 int32_t dx = sdci[7]/10000;
2396 937483 int32_t dy = sdci[8]/10000;
2397 937483 int32_t dw = sdci[9]/10000;
2398 937483 int32_t dh = sdci[10]/10000;
2399 937483 float rot = sdci[11]/10000;
2400 937483 bool masked = (sdci[12] != 0);
2401
2402 //bugfix
2403 937483 sx = vbound(sx, 0, 512);
2404 937483 sy = vbound(sy, 0, 512);
2405 937483 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2406 937483 sh = vbound(sh, 0, 512 - sy);
2407
2408
2409
2/4
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 937483 times.
937483 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2410 return;
2411
2412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 937483 times.
937483 bool stretched = (sw != dw || sh != dh);
2413
2414 937483 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2415
2416
1/2
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
937483 if(!sourceBitmap)
2417 {
2418 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2419 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2420 return;
2421 }
2422
2423 937483 BITMAP* subBmp = 0;
2424
2425
1/2
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
937483 if(rot != 0)
2426 {
2427 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2428
2429 if(!subBmp)
2430 {
2431 Z_scripterrlog("DrawBitmap() failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2432 return;
2433 }
2434 }
2435
2436
2437 937483 dx = dx + xoffset;
2438 937483 dy = dy + yoffset;
2439
2440
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 937243 times.
937483 if(stretched)
2441 {
2442
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(masked)
2443 {
2444
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(rot != 0)
2445 {
2446 //if ( rot == 4096 ) { //translucent
2447 // masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2448 // //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2449 // draw_trans_sprite(bmp, subBmp, dx, dy);
2450 // //draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, 0);
2451
2452
2453 // }
2454 //else {
2455 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2456 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2457 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2458 //
2459
2460 // }
2461 }
2462 else
2463 240 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2464 240 }
2465 else
2466 {
2467 if(rot != 0)
2468 {
2469 //if ( rot == 4096 ) { //translucent
2470 // stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2471 // draw_trans_sprite(bmp, subBmp, dx, dy);
2472 // }
2473 //else {
2474 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2475 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2476 // }
2477 }
2478 else
2479 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2480 }
2481 240 }
2482 else
2483 {
2484
2/2
✓ Branch 0 taken 929755 times.
✓ Branch 1 taken 7488 times.
937243 if(masked)
2485 {
2486
1/2
✓ Branch 0 taken 929755 times.
✗ Branch 1 not taken.
929755 if(rot != 0)
2487 {
2488 //if ( rot == 4096 ) {//translucent
2489 // masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2490 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2491
2492 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2493 //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2494 // draw_trans_sprite(bmp, subBmp, dx, dy);
2495 // }
2496 //else {
2497 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2498 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2499 // }
2500 }
2501 else
2502 929755 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2503 929755 }
2504 else
2505 {
2506
1/2
✓ Branch 0 taken 7488 times.
✗ Branch 1 not taken.
7488 if(rot != 0)
2507 {
2508 //if ( rot == 4096 ) { //translucent
2509 // blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2510 // draw_trans_sprite(bmp, subBmp, dx, dy);
2511 // }
2512 //else {
2513 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2514 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2515 // }
2516 }
2517 else
2518 7488 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2519 }
2520 }
2521
2522 //cleanup
2523
1/2
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
937483 if(subBmp)
2524 {
2525 script_drawing_commands.ReleaseSubBitmap(subBmp);
2526 }
2527 937483 }
2528
2529
2530 //Draw]()
2531 void do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2532 {
2533 /*
2534 //sdci[1]=layer
2535 //sdci[2]=bitmap
2536 //sdci[3]=sourcex
2537 //sdci[4]=sourcey
2538 //sdci[5]=sourcew
2539 //sdci[6]=sourceh
2540 //sdci[7]=destx
2541 //sdci[8]=desty
2542 //sdci[9]=destw
2543 //sdci[10]=desth
2544 //sdci[11]=rotation/angle
2545 //scdi[12] = pivot cx
2546 //sdci[13] = pivot cy
2547 //scdi[14] = effect flags
2548
2549
2550 const int32_t BITDX_NORMAL = 0;
2551 const int32_t BITDX_TRANS = 1; //Translucent
2552 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
2553 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
2554 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
2555 //Note: Some modes cannot be combined. if a combination is not supported, an error
2556 // detailing this will be shown in allegro.log.
2557
2558 //scdi[15] = litcolour
2559 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2560 /not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2561
2562 //sdci[16]=mask
2563
2564 */
2565
2566 int32_t bitmapIndex = sdci[2]/10000;
2567 int32_t sx = sdci[3]/10000;
2568 int32_t sy = sdci[4]/10000;
2569 int32_t sw = sdci[5]/10000;
2570 int32_t sh = sdci[6]/10000;
2571 int32_t dx = sdci[7]/10000;
2572 int32_t dy = sdci[8]/10000;
2573 int32_t dw = sdci[9]/10000;
2574 int32_t dh = sdci[10]/10000;
2575 float rot = sdci[11]/10000;
2576 int32_t cx = sdci[12]/10000;
2577 int32_t cy = sdci[13]/10000;
2578 int32_t mode = sdci[14]/10000;
2579 int32_t litcolour = sdci[15]/10000;
2580 bool masked = (sdci[16] != 0);
2581
2582
2583
2584 //bugfix
2585 sx = vbound(sx, 0, 512);
2586 sy = vbound(sy, 0, 512);
2587 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2588 sh = vbound(sh, 0, 512 - sy);
2589
2590
2591 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2592 return;
2593
2594 bool stretched = (sw != dw || sh != dh);
2595
2596 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2597
2598 if(!sourceBitmap)
2599 {
2600 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2601 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2602 return;
2603 }
2604
2605 BITMAP* subBmp = 0;
2606
2607 /*
2608 if ( bitmapIndex == -1 ) {
2609 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
2610 }
2611 */
2612
2613 if(rot != 0 || mode != 0)
2614 {
2615 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2616
2617 if(!subBmp)
2618 {
2619 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2620 return;
2621 }
2622 }
2623
2624
2625 dx = dx + xoffset;
2626 dy = dy + yoffset;
2627
2628 if(stretched)
2629 {
2630 if(masked) //stretched and masked
2631 {
2632 if ( rot == 0 ) //if not rotated
2633 {
2634 switch(mode)
2635 {
2636 case 1:
2637 //transparent
2638 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2639 draw_trans_sprite(bmp, subBmp, dx, dy);
2640 break;
2641
2642
2643 case 2:
2644 //pivot?
2645 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2646 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2647 //Pivoting requires two more args
2648 break;
2649
2650 case 3:
2651 //pivot + trans
2652 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2653 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2654 break;
2655
2656 case 4:
2657 //flip v
2658 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2659 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2660 break;
2661
2662 case 5:
2663 //trans + v flip
2664 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2665 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2666 break;
2667
2668 case 6:
2669 //pivot + v flip
2670 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2671 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2672 break;
2673
2674 case 8:
2675 //vlip h
2676 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2677 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2678 break;
2679
2680 case 9:
2681 //trans + h flip
2682 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2683 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2684 break;
2685
2686 case 10:
2687 //flip H and pivot
2688 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2689 //return error cannot pivot and h flip
2690 break;
2691
2692 case 12:
2693 //vh flip
2694 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2695 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2696 break;
2697
2698 case 13:
2699 //trans + vh flip
2700 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2701 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2702 break;
2703
2704 case 14:
2705 //pivot and vh flip
2706 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2707 //return error cannot both pivot and vh flip
2708 break;
2709
2710 case 16:
2711 //lit
2712 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2713 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2714 break;
2715
2716 case 18:
2717 //pivot, lit
2718 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2719 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2720 break;
2721
2722 case 20:
2723 //lit + v flip
2724 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2725 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
2726 break;
2727
2728 case 22:
2729 //Pivot, vflip, lit
2730 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2731 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2732 break;
2733
2734 case 24:
2735 //lit + h flip
2736 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2737 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
2738 break;
2739
2740 case 26:
2741 //pivot + lit + hflip
2742 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
2743 //return error cannot pivot, lit, and flip
2744 break;
2745
2746 case 28:
2747 //lit + vh flip
2748 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2749 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
2750 break;
2751
2752 case 32: //gouraud
2753 //Probably not wort supporting.
2754 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2755 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2756 break;
2757
2758 case 0:
2759 //no effect
2760 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2761 break;
2762
2763
2764 default:
2765 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2766
2767
2768 }
2769 } //end if not rotated
2770
2771 if ( rot != 0 ) //if rotated
2772 {
2773 switch(mode)
2774 {
2775 case 1:
2776 //transparent
2777 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2778 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2779
2780 break;
2781
2782 case 2:
2783 //pivot?
2784 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2785 //return an error, cannot both rotate and pivot
2786 break;
2787
2788 case 3:
2789 //pivot + trans
2790 //return an error, cannot both rotate and pivot
2791 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2792 break;
2793
2794 case 4:
2795 //flip v
2796 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2797 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2798 break;
2799
2800 case 5:
2801 //trans + v flip
2802 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2803 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2804 break;
2805
2806 case 6:
2807 //pivot + v flip
2808 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2809 //return an error, cannot both rotate and pivot
2810 break;
2811
2812 case 8:
2813 //flip h
2814 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
2815 //return an error, cannot both rotate and flip H
2816 break;
2817
2818 case 9:
2819 //trans + h flip
2820 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
2821 //return an error, cannot rotate and flip a trans sprite
2822 break;
2823
2824 case 10:
2825 //flip H and pivot
2826 //return error cannot pivot and h flip
2827 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2828 break;
2829
2830 case 12:
2831 //vh flip
2832 //return an error, cannot rotate and VH flip a trans sprite
2833 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2834 break;
2835
2836 case 13:
2837 //trans + vh flip
2838 //return an error, cannot rotate and VH flip a trans sprite
2839 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2840 break;
2841
2842 case 14:
2843 //pivot and vh flip
2844 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2845 //return error cannot both pivot and vh flip
2846 break;
2847
2848 case 16:
2849 //lit
2850 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2851 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2852 break;
2853
2854 case 18:
2855 //pivot, lit
2856 //return an error, cannot both rotate and pivot
2857 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2858 break;
2859
2860 case 20:
2861 //lit + vflip
2862 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2863 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2864 break;
2865
2866 case 22:
2867 //Pivot, vflip, lit
2868 //return an error, cannot both rotate and pivot
2869 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2870 break;
2871
2872 case 24:
2873 //lit + h flip
2874 //return an error, cannot both rotate and H flip
2875 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
2876 break;
2877
2878 case 26:
2879 //pivot + lit + hflip
2880 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
2881 //return error cannot pivot, lit, and flip
2882 break;
2883
2884 case 28:
2885 //lit + vh flip
2886 //return an error, cannot both rotate and VH flip
2887 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2888 break;
2889
2890 case 32: //gouraud
2891 //Probably not wort supporting.
2892 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2893 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2894 break;
2895
2896 case 0:
2897 //no effect.
2898 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2899 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2900 break;
2901
2902 default:
2903 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2904
2905 }
2906 }
2907 } //end if stretched and masked
2908
2909 else //stretched, not masked
2910 {
2911 if ( rot == 0 ) //if not rotated
2912 {
2913 switch(mode) {
2914 case 1:
2915 //transparent
2916 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2917 draw_trans_sprite(bmp, subBmp, dx, dy);
2918 break;
2919
2920
2921 case 2:
2922 //pivot?
2923 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2924 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2925 //Pivoting requires two more args
2926 break;
2927
2928 case 3:
2929 //pivot + trans
2930 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2931 pivot_sprite_trans(bmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
2932 break;
2933
2934 case 4:
2935 //flip v
2936 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2937 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2938 break;
2939
2940 case 5:
2941 //trans + v flip
2942 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2943 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2944 break;
2945
2946 case 6:
2947 //pivot + v flip
2948 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2949 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2950 break;
2951
2952 case 8:
2953 //vlip h
2954 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2955 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2956 break;
2957
2958 case 9:
2959 //trans + h flip
2960 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2961 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2962 break;
2963
2964 case 10:
2965 //flip H and pivot
2966 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2967 //return error cannot pivot and h flip
2968 break;
2969
2970 case 12:
2971 //vh flip
2972 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2973 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2974 break;
2975
2976 case 13:
2977 //trans + vh flip
2978 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2979 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2980 break;
2981
2982 case 14:
2983 //pivot and vh flip
2984 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2985 //return error cannot both pivot and vh flip
2986 break;
2987
2988 case 16:
2989 //lit
2990 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2991 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2992 break;
2993
2994 case 18:
2995 //pivot, lit
2996 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2997 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2998 break;
2999
3000 case 20:
3001 //lit + v flip
3002 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3003 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3004 break;
3005
3006 case 22:
3007 //Pivot, vflip, lit
3008 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3009 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3010 break;
3011
3012 case 24:
3013 //lit + h flip
3014 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3015 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3016 break;
3017
3018 case 26:
3019 //pivot + lit + hflip
3020 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3021 //return error cannot pivot, lit, and flip
3022 break;
3023
3024 case 28:
3025 //lit + vh flip
3026 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3027 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3028 break;
3029
3030 case 32: //gouraud
3031 //Probably not wort supporting.
3032 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3033 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3034 break;
3035
3036 case 0:
3037 //no effect
3038 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
3039 break;
3040
3041
3042 default:
3043 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3044
3045
3046 }
3047 } //end if not rotated
3048
3049 if ( rot != 0 ) //if rotated
3050 {
3051 switch(mode)
3052 {
3053 case 1:
3054 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3055 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3056
3057 break;
3058
3059 case 2:
3060 //pivot?
3061 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3062 //return an error, cannot both rotate and pivot
3063 break;
3064
3065 case 3:
3066 //pivot + trans
3067 //return an error, cannot both rotate and pivot
3068 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3069 break;
3070
3071 case 4:
3072 //flip v
3073 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3074 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3075 break;
3076
3077 case 5:
3078 //trans + v flip
3079 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3080 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3081 break;
3082
3083 case 6:
3084 //pivot + v flip
3085 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3086 //return an error, cannot both rotate and pivot
3087 break;
3088
3089 case 8:
3090 //flip h
3091 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3092 //return an error, cannot both rotate and flip H
3093 break;
3094
3095 case 9:
3096 //trans + h flip
3097 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3098 //return an error, cannot rotate and flip a trans sprite
3099 break;
3100
3101 case 10:
3102 //flip H and pivot
3103 //return error cannot pivot and h flip
3104 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3105 break;
3106
3107 case 12:
3108 //vh flip
3109 //return an error, cannot rotate and VH flip a trans sprite
3110 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3111 break;
3112
3113 case 13:
3114 //trans + vh flip
3115 //return an error, cannot rotate and VH flip a trans sprite
3116 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3117 break;
3118
3119 case 14:
3120 //pivot and vh flip
3121 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3122 //return error cannot both pivot and vh flip
3123 break;
3124
3125 case 16:
3126 //lit
3127 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3128 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3129 break;
3130
3131 case 18:
3132 //pivot, lit
3133 //return an error, cannot both rotate and pivot
3134 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3135 break;
3136
3137 case 20:
3138 //lit + vflip
3139 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3140 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3141 break;
3142
3143 case 22:
3144 //Pivot, vflip, lit
3145 //return an error, cannot both rotate and pivot
3146 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3147 break;
3148
3149 case 24:
3150 //lit + h flip
3151 //return an error, cannot both rotate and H flip
3152 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3153 break;
3154
3155 case 26:
3156 //pivot + lit + hflip
3157 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3158 //return error cannot pivot, lit, and flip
3159 break;
3160
3161 case 28:
3162 //lit + vh flip
3163 //return an error, cannot both rotate and VH flip
3164 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3165 break;
3166
3167 case 32: //gouraud
3168 //Probably not wort supporting.
3169 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3170 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3171 break;
3172
3173 case 0:
3174 //no effect.
3175 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3176 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3177 break;
3178
3179 default:
3180 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3181
3182 }
3183 }
3184
3185 } //end if stretched, but not masked
3186 }
3187 else //not stretched
3188 {
3189
3190 if(masked) //if masked, but not stretched
3191 {
3192
3193 if ( rot == 0 ) //if not rotated
3194 {
3195 switch(mode)
3196 {
3197 case 1:
3198 //transparent
3199 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3200 draw_trans_sprite(bmp, subBmp, dx, dy);
3201 break;
3202
3203
3204 case 2:
3205 //pivot?
3206 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3207 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3208 //Pivoting requires two more args
3209 break;
3210
3211 case 3:
3212 //pivot + trans
3213 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3214 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3215 break;
3216
3217 case 4:
3218 //flip v
3219 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3220 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3221 break;
3222
3223 case 5:
3224 //trans + v flip
3225 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3226 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3227 break;
3228
3229 case 6:
3230 //pivot + v flip
3231 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3232 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3233 break;
3234
3235 case 8:
3236 //vlip h
3237 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3238 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3239 break;
3240
3241 case 9:
3242 //trans + h flip
3243 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3244 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3245 break;
3246
3247 case 10:
3248 //flip H and pivot
3249 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3250 //return error cannot pivot and h flip
3251 break;
3252
3253 case 12:
3254 //vh flip
3255 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3256 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3257 break;
3258
3259 case 13:
3260 //trans + vh flip
3261 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3262 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3263 break;
3264
3265 case 14:
3266 //pivot and vh flip
3267 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3268 //return error cannot both pivot and vh flip
3269 break;
3270
3271 case 16:
3272 //lit
3273 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3274 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3275 break;
3276
3277 case 18:
3278 //pivot, lit
3279 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3280 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3281 break;
3282
3283 case 20:
3284 //lit + v flip
3285 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3286 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3287 break;
3288
3289 case 22:
3290 //Pivot, vflip, lit
3291 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3292 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3293 break;
3294
3295 case 24:
3296 //lit + h flip
3297 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3298 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3299 break;
3300
3301 case 26:
3302 //pivot + lit + hflip
3303 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3304 //return error cannot pivot, lit, and flip
3305 break;
3306
3307 case 28:
3308 //lit + vh flip
3309 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3310 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3311 break;
3312
3313 case 32: //gouraud
3314 //Probably not wort supporting.
3315 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3316 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3317 break;
3318
3319 case 0:
3320 //no effect
3321 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3322 break;
3323
3324
3325 default:
3326 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3327
3328
3329 }
3330 } //end if not rotated
3331
3332 if ( rot != 0 ) //if rotated
3333 {
3334 switch(mode)
3335 {
3336 case 1:
3337 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //transparent
3338 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3339
3340 break;
3341
3342 case 2:
3343 //pivot?
3344 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3345 //return an error, cannot both rotate and pivot
3346 break;
3347
3348 case 3:
3349 //pivot + trans
3350 //return an error, cannot both rotate and pivot
3351 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3352 break;
3353
3354 case 4:
3355 //flip v
3356 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3357 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3358 break;
3359
3360 case 5:
3361 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
3362 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3363 break;
3364
3365 case 6:
3366 //pivot + v flip
3367 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3368 //return an error, cannot both rotate and pivot
3369 break;
3370
3371 case 8:
3372 //flip h
3373 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3374 //return an error, cannot both rotate and flip H
3375 break;
3376
3377 case 9:
3378 //trans + h flip
3379 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3380 //return an error, cannot rotate and flip a trans sprite
3381 break;
3382
3383 case 10:
3384 //flip H and pivot
3385 //return error cannot pivot and h flip
3386 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3387 break;
3388
3389 case 12:
3390 //vh flip
3391 //return an error, cannot rotate and VH flip a trans sprite
3392 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3393 break;
3394
3395 case 13:
3396 //trans + vh flip
3397 //return an error, cannot rotate and VH flip a trans sprite
3398 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3399 break;
3400
3401 case 14:
3402 //pivot and vh flip
3403 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3404 //return error cannot both pivot and vh flip
3405 break;
3406
3407 case 16:
3408 //lit
3409 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3410 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3411 break;
3412
3413 case 18:
3414 //pivot, lit
3415 //return an error, cannot both rotate and pivot
3416 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3417 break;
3418
3419 case 20:
3420 //lit + vflip
3421 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3422 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3423 break;
3424
3425 case 22:
3426 //Pivot, vflip, lit
3427 //return an error, cannot both rotate and pivot
3428 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3429 break;
3430
3431 case 24:
3432 //lit + h flip
3433 //return an error, cannot both rotate and H flip
3434 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3435 break;
3436
3437 case 26:
3438 //pivot + lit + hflip
3439 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3440 //return error cannot pivot, lit, and flip
3441 break;
3442
3443 case 28:
3444 //lit + vh flip
3445 //return an error, cannot both rotate and VH flip
3446 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3447 break;
3448
3449 case 32: //gouraud
3450 //Probably not wort supporting.
3451 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3452 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3453 break;
3454
3455 case 0:
3456 //no effect.
3457 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3458 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3459 break;
3460
3461 default:
3462 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3463
3464 }
3465 } //end rtated, masked
3466 } //end if masked
3467
3468 else //not masked, and not stretched; just blit
3469 {
3470
3471 if ( rot == 0 ) //if not rotated
3472 {
3473 switch(mode)
3474 {
3475 case 1:
3476 //transparent
3477 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3478 draw_trans_sprite(bmp, subBmp, dx, dy);
3479 break;
3480
3481
3482 case 2:
3483 //pivot?
3484 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3485 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3486 //Pivoting requires two more args
3487 break;
3488
3489 case 3:
3490 //pivot + trans
3491 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3492 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3493 break;
3494
3495 case 4:
3496 //flip v
3497 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3498 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3499 break;
3500
3501 case 5:
3502 //trans + v flip
3503 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3504 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3505 break;
3506
3507 case 6:
3508 //pivot + v flip
3509 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3510 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3511 break;
3512
3513 case 8:
3514 //vlip h
3515 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3516 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3517 break;
3518
3519 case 9:
3520 //trans + h flip
3521 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3522 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3523 break;
3524
3525 case 10:
3526 //flip H and pivot
3527 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3528 //return error cannot pivot and h flip
3529 break;
3530
3531 case 12:
3532 //vh flip
3533 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3534 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3535 break;
3536
3537 case 13:
3538 //trans + vh flip
3539 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3540 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3541 break;
3542
3543 case 14:
3544 //pivot and vh flip
3545 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3546 //return error cannot both pivot and vh flip
3547 break;
3548
3549 case 16:
3550 //lit
3551 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3552 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3553 break;
3554
3555 case 18:
3556 //pivot, lit
3557 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3558 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3559 break;
3560
3561 case 20:
3562 //lit + v flip
3563 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3564 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3565 break;
3566
3567 case 22:
3568 //Pivot, vflip, lit
3569 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3570 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3571 break;
3572
3573 case 24:
3574 //lit + h flip
3575 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3576 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3577 break;
3578
3579 case 26:
3580 //pivot + lit + hflip
3581 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3582 //return error cannot pivot, lit, and flip
3583 break;
3584
3585 case 28:
3586 //lit + vh flip
3587 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3588 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3589 break;
3590
3591 case 32: //gouraud
3592 //Probably not wort supporting.
3593 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3594 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3595 break;
3596
3597 case 0:
3598 //no effect
3599 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3600 break;
3601
3602
3603 default:
3604 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3605
3606
3607 }
3608 } //end if not rotated
3609
3610 if ( rot != 0 ) //if rotated
3611 {
3612 switch(mode)
3613 {
3614 case 1:
3615 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);//transparent
3616 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3617
3618 break;
3619
3620 case 2:
3621 //pivot?
3622 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3623 //return an error, cannot both rotate and pivot
3624 break;
3625
3626 case 3:
3627 //pivot + trans
3628 //return an error, cannot both rotate and pivot
3629 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3630 break;
3631
3632 case 4:
3633 //flip v
3634 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3635 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3636 break;
3637
3638 case 5:
3639 //trans + v flip
3640 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3641 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3642 break;
3643
3644 case 6:
3645 //pivot + v flip
3646 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3647 //return an error, cannot both rotate and pivot
3648 break;
3649
3650 case 8:
3651 //flip h
3652 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3653 //return an error, cannot both rotate and flip H
3654 break;
3655
3656 case 9:
3657 //trans + h flip
3658 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3659 //return an error, cannot rotate and flip a trans sprite
3660 break;
3661
3662 case 10:
3663 //flip H and pivot
3664 //return error cannot pivot and h flip
3665 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3666 break;
3667
3668 case 12:
3669 //vh flip
3670 //return an error, cannot rotate and VH flip a trans sprite
3671 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3672 break;
3673
3674 case 13:
3675 //trans + vh flip
3676 //return an error, cannot rotate and VH flip a trans sprite
3677 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3678 break;
3679
3680 case 14:
3681 //pivot and vh flip
3682 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3683 //return error cannot both pivot and vh flip
3684 break;
3685
3686 case 16:
3687 //lit
3688 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3689 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3690 break;
3691
3692 case 18:
3693 //pivot, lit
3694 //return an error, cannot both rotate and pivot
3695 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3696 break;
3697
3698 case 20:
3699 //lit + vflip
3700 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3701 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3702 break;
3703
3704 case 22:
3705 //Pivot, vflip, lit
3706 //return an error, cannot both rotate and pivot
3707 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3708 break;
3709
3710 case 24:
3711 //lit + h flip
3712 //return an error, cannot both rotate and H flip
3713 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3714 break;
3715
3716 case 26:
3717 //pivot + lit + hflip
3718 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3719 //return error cannot pivot, lit, and flip
3720 break;
3721
3722 case 28:
3723 //lit + vh flip
3724 //return an error, cannot both rotate and VH flip
3725 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3726 break;
3727
3728 case 32: //gouraud
3729 //Probably not wort supporting.
3730 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3731 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3732 break;
3733
3734 case 0:
3735 //no effect.
3736 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3737 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3738 break;
3739
3740 default:
3741 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3742
3743 }
3744 } //end if rotated
3745 } //end if not masked
3746 } //end if not stretched
3747
3748 //cleanup
3749 if(subBmp)
3750 {
3751 script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
3752 }
3753 }
3754
3755
3756 void do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3757 {
3758 //sdci[1]=layer
3759 //sdci[2]=pos[12]
3760 //sdci[3]=uv[8]
3761 //sdci[4]=color[4]
3762 //sdci[5]=size[2]
3763 //sdci[6]=flip
3764 //sdci[7]=tile/combo
3765 //sdci[8]=polytype
3766
3767 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3768
3769 if(!v_ptr)
3770 {
3771 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
3772 return;
3773 }
3774
3775 std::vector<int32_t> &v = *v_ptr;
3776
3777 if(v.empty())
3778 return;
3779
3780 int32_t* pos = &v[0];
3781 int32_t* uv = &v[12];
3782 int32_t* col = &v[20];
3783 int32_t* size = &v[24];
3784
3785 int32_t w = size[0]; //magic numerical constants... yuck.
3786 int32_t h = size[1];
3787 int32_t flip = (sdci[6]/10000)&3;
3788 int32_t tile = sdci[7]/10000;
3789 int32_t polytype = sdci[8]/10000;
3790
3791 polytype = vbound(polytype, 0, 14);
3792
3793 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3794 {
3795 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3796 return; //non power of two error
3797 }
3798
3799 int32_t tex_width = w*16;
3800 int32_t tex_height = h*16;
3801
3802 bool mustDestroyBmp = false;
3803 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3804
3805 if(!tex)
3806 {
3807 mustDestroyBmp = true;
3808 tex = create_bitmap_ex(8, tex_width, tex_height);
3809 clear_bitmap(tex);
3810 }
3811
3812 if(tile > 0) // TILE
3813 {
3814 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3815 }
3816 else // COMBO
3817 {
3818 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
3819 const int32_t tiletodraw = combo_tile(c, 0, 0);
3820 flip = flip ^ c.flip;
3821
3822 if(!(c.animflags & AF_EDITOR_ONLY))
3823 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3824 }
3825
3826 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3827 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3828 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3829 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
3830
3831 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
3832
3833 if(mustDestroyBmp)
3834 destroy_bitmap(tex);
3835
3836 }
3837
3838
3839
3840 void do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3841 {
3842 //sdci[1]=layer
3843 //sdci[2]=pos[9]
3844 //sdci[3]=uv[6]
3845 //sdci[4]=color[3]
3846 //sdci[5]=size[2]
3847 //sdci[6]=flip
3848 //sdci[7]=tile/combo
3849 //sdci[8]=polytype
3850
3851 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3852
3853 if(!v_ptr)
3854 {
3855 al_trace("Triange3d: Vector pointer is null! Internal error. \n");
3856 return;
3857 }
3858
3859 std::vector<int32_t> &v = *v_ptr;
3860
3861 if(v.empty())
3862 return;
3863
3864 int32_t* pos = &v[0];
3865 int32_t* uv = &v[9];
3866 int32_t* col = &v[15];
3867 int32_t* size = &v[18];
3868
3869 int32_t w = size[0]; //magic numerical constants... yuck.
3870 int32_t h = size[1];
3871 int32_t flip = (sdci[6]/10000)&3;
3872 int32_t tile = sdci[7]/10000;
3873 int32_t polytype = sdci[8]/10000;
3874
3875 polytype = vbound(polytype, 0, 14);
3876
3877 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3878 {
3879 Z_message("Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3880 return; //non power of two error
3881 }
3882
3883 int32_t tex_width = w*16;
3884 int32_t tex_height = h*16;
3885
3886 bool mustDestroyBmp = false;
3887 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3888
3889 if(!tex)
3890 {
3891 mustDestroyBmp = true;
3892 tex = create_bitmap_ex(8, tex_width, tex_height);
3893 clear_bitmap(tex);
3894 }
3895
3896 if(tile > 0) // TILE
3897 {
3898 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3899 }
3900 else // COMBO
3901 {
3902 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
3903 const int32_t tiletodraw = combo_tile(c, 0, 0);
3904 flip = flip ^ c.flip;
3905
3906 if(!(c.animflags & AF_EDITOR_ONLY))
3907 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3908 }
3909
3910 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3911 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3912 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3913
3914 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
3915
3916 if(mustDestroyBmp)
3917 destroy_bitmap(tex);
3918
3919 }
3920
3921 12431 void bmp_do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3922 {
3923 //Z_scripterrlog("rect sdci[13] is: %d\n", sdci[13]);
3924 //sdci[1]=layer
3925 //sdci[2]=x
3926 //sdci[3]=y
3927 //sdci[4]=x2
3928 //sdci[5]=y2
3929 //sdci[6]=color
3930 //sdci[7]=scale factor
3931 //sdci[8]=rotation anchor x
3932 //sdci[9]=rotation anchor y
3933 //sdci[10]=rotation angle
3934 //sdci[11]=fill
3935 //sdci[12]=opacity
3936 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
3937
1/2
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
12431 if(sdci[7]==0) //scale
3938 {
3939 return;
3940 }
3941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12431 times.
12431 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
3942 {
3943 Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
3944 return;
3945 }
3946 12431 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
3947
1/2
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
12431 if ( refbmp == NULL ) return;
3948
3949
2/4
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12431 times.
12431 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
3950
3951 12431 int32_t x1=sdci[2]/10000;
3952 12431 int32_t y1=sdci[3]/10000;
3953 12431 int32_t x2=sdci[4]/10000;
3954 12431 int32_t y2=sdci[5]/10000;
3955
3956
3957
2/2
✓ Branch 0 taken 12427 times.
✓ Branch 1 taken 4 times.
12431 if(x1>x2)
3958 {
3959 4 zc_swap(x1,x2);
3960 4 }
3961
3962
2/2
✓ Branch 0 taken 11147 times.
✓ Branch 1 taken 1284 times.
12431 if(y1>y2)
3963 {
3964 1284 zc_swap(y1,y2);
3965 1284 }
3966
3967
2/2
✓ Branch 0 taken 11151 times.
✓ Branch 1 taken 1280 times.
12431 if(sdci[7] != 10000)
3968 {
3969 1280 int32_t w=x2-x1+1;
3970 1280 int32_t h=y2-y1+1;
3971 1280 int32_t w2=(w*sdci[7])/10000;
3972 1280 int32_t h2=(h*sdci[7])/10000;
3973 1280 x1=x1-((w2-w)/2);
3974 1280 x2=x2+((w2-w)/2);
3975 1280 y1=y1-((h2-h)/2);
3976 1280 y2=y2+((h2-h)/2);
3977 1280 }
3978
3979 12431 int32_t color=sdci[6]/10000;
3980
3981
2/2
✓ Branch 0 taken 12303 times.
✓ Branch 1 taken 128 times.
12431 if(sdci[12]/10000<=127) //translucent
3982 {
3983 128 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
3984 128 }
3985
3986
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12335 times.
12431 if(sdci[10]==0) //no rotation
3987 {
3988
2/2
✓ Branch 0 taken 9143 times.
✓ Branch 1 taken 3192 times.
12335 if(sdci[11]) //filled
3989 {
3990 9143 rectfill(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3991 9143 }
3992 else //outline
3993 {
3994 3192 rect(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3995 }
3996 12335 }
3997 else //rotate
3998 {
3999 int32_t xy[16];
4000 96 int32_t rx=sdci[8]/10000;
4001 96 int32_t ry=sdci[9]/10000;
4002 96 fixed ra1=itofix(sdci[10]%10000)/10000;
4003 96 fixed ra2=itofix(sdci[10]/10000);
4004 96 fixed ra=ra1+ra2;
4005 96 ra = (ra/360)*256;
4006
4007 96 fixed fcosa = fixcos(ra);
4008 96 fixed fsina = fixsin(ra);
4009
4010 96 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
4011 96 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
4012 96 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
4013 96 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
4014 96 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
4015 96 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
4016 96 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
4017 96 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
4018 96 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
4019 96 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
4020 96 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
4021 96 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
4022 96 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
4023 96 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
4024 96 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
4025 96 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
4026
4027
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sdci[11]) //filled
4028 {
4029 96 polygon(refbmp, 4, xy, color);
4030 96 }
4031 else //outline
4032 {
4033 line(refbmp, xy[0], xy[1], xy[10], xy[11], color);
4034 line(refbmp, xy[2], xy[3], xy[12], xy[13], color);
4035 line(refbmp, xy[4], xy[5], xy[14], xy[15], color);
4036 line(refbmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
4037 }
4038 }
4039
4040 12431 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4041 12431 }
4042
4043 void bmp_do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4044 {
4045 //sdci[1]=layer
4046 //sdci[2]=x
4047 //sdci[3]=y
4048 //sdci[4]=tile
4049 //sdci[5]=cset
4050 //sdci[6]=width
4051 //sdci[7]=height
4052 //sdci[8]=overlay
4053 //sdci[9]=opacity
4054
4055 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4056 {
4057 Z_scripterrlog("bitmap->DrawFrame() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4058 return;
4059 }
4060 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4061 if ( refbmp == NULL ) return;
4062
4063 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4064
4065 int32_t x=sdci[2]/10000;
4066 int32_t y=sdci[3]/10000;
4067
4068 int32_t tile=sdci[4]/10000;
4069 int32_t cs=sdci[5]/10000;
4070 int32_t w=sdci[6]/10000;
4071 int32_t h=sdci[7]/10000;
4072 bool overlay=sdci[8];
4073 bool trans=(sdci[9]/10000<=127);
4074
4075 frame2x2(refbmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
4076 }
4077
4078
4079 192290 void bmp_do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4080 {
4081 //sdci[1]=layer
4082 //sdci[2]=x
4083 //sdci[3]=y
4084 //sdci[4]=radius
4085 //sdci[5]=color
4086 //sdci[6]=scale factor
4087 //sdci[7]=rotation anchor x
4088 //sdci[8]=rotation anchor y
4089 //sdci[9]=rotation angle
4090 //sdci[10]=fill
4091 //sdci[11]=opacity
4092 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4093
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[6]==0) //scale
4094 {
4095 return;
4096 }
4097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192290 times.
192290 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4098 {
4099 Z_scripterrlog("bitmap->Circle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4100 return;
4101 }
4102 192290 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4103
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if ( refbmp == NULL ) return;
4104
4105
2/4
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192290 times.
192290 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4106
4107 192290 int32_t x1=sdci[2]/10000;
4108 192290 int32_t y1=sdci[3]/10000;
4109 192290 qword r=sdci[4];
4110
4111
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[6] != 10000)
4112 {
4113 r*=sdci[6];
4114 r/=10000;
4115 }
4116
4117 192290 r/=10000;
4118 192290 int32_t color=sdci[5]/10000;
4119
4120
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[11]/10000<=127) //translucent
4121 {
4122 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4123 }
4124
4125
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 192290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
192290 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
4126 {
4127 int32_t xy[2];
4128 int32_t rx=sdci[7]/10000;
4129 int32_t ry=sdci[8]/10000;
4130 fixed ra1=itofix(sdci[9]%10000)/10000;
4131 fixed ra2=itofix(sdci[9]/10000);
4132 fixed ra=ra1+ra2;
4133 ra = (ra/360)*256;
4134
4135 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4136 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4137 x1=xy[0];
4138 y1=xy[1];
4139 }
4140
4141
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[10]) //filled
4142 {
4143 192290 circlefill(refbmp, x1+xoffset, y1+yoffset, r, color);
4144 192290 }
4145 else //outline
4146 {
4147 circle(refbmp, x1+xoffset, y1+yoffset, r, color);
4148 }
4149
4150 192290 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4151 192290 }
4152
4153
4154 void bmp_do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4155 {
4156 //sdci[1]=layer
4157 //sdci[2]=x
4158 //sdci[3]=y
4159 //sdci[4]=radius
4160 //sdci[5]=start angle
4161 //sdci[6]=end angle
4162 //sdci[7]=color
4163 //sdci[8]=scale factor
4164 //sdci[9]=rotation anchor x
4165 //sdci[10]=rotation anchor y
4166 //sdci[11]=rotation angle
4167 //sdci[12]=closed
4168 //sdci[13]=fill
4169 //sdci[14]=opacity
4170 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4171
4172 if(sdci[8]==0) //scale
4173 {
4174 return;
4175 }
4176 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4177 {
4178 Z_scripterrlog("bitmap->Arc() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4179 return;
4180 }
4181 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4182 if ( refbmp == NULL ) return;
4183
4184 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4185
4186 int32_t cx=sdci[2]/10000;
4187 int32_t cy=sdci[3]/10000;
4188 qword r=sdci[4];
4189
4190 if(sdci[8] != 10000)
4191 {
4192 r*=sdci[8];
4193 r/=10000;
4194 }
4195
4196 r/=10000;
4197
4198 int32_t color=sdci[7]/10000;
4199
4200 fixed ra1=itofix(sdci[11]%10000)/10000;
4201 fixed ra2=itofix(sdci[11]/10000);
4202 fixed ra=ra1+ra2;
4203 ra = (ra/360)*256;
4204
4205
4206 fixed a1=itofix(sdci[5]%10000)/10000;
4207 fixed a2=itofix(sdci[5]/10000);
4208 fixed sa=a1+a2;
4209 sa = (sa/360)*256;
4210
4211 a1=itofix(sdci[6]%10000)/10000;
4212 a2=itofix(sdci[6]/10000);
4213 fixed ea=a1+a2;
4214 ea = (ea/360)*256;
4215
4216 if(sdci[11]!=0) //rotation
4217 {
4218 int32_t rx=sdci[9]/10000;
4219 int32_t ry=sdci[10]/10000;
4220
4221 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
4222 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
4223 ea-=ra;
4224 sa-=ra;
4225 }
4226
4227 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
4228 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
4229
4230 if(sdci[12]) //closed
4231 {
4232 if(sdci[13]) //filled
4233 {
4234 clear_bitmap(prim_bmp);
4235 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4236 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4237 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4238 int fillx = zc_max(0,fx)+xoffset;
4239 int filly = zc_max(0,fy)+yoffset;
4240 zprint2("bitmap->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
4241 floodfill(prim_bmp, fillx, filly, color);
4242
4243 if(sdci[14]/10000<=127) //translucent
4244 {
4245 draw_trans_sprite(refbmp, prim_bmp, 0,0);
4246 }
4247 else
4248 {
4249 draw_sprite(refbmp, prim_bmp, 0,0);
4250 }
4251 }
4252 else
4253 {
4254 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4255 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4256 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4257 }
4258 }
4259 else
4260 {
4261 if(sdci[14]/10000<=127) //translucent
4262 {
4263 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4264 }
4265
4266 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4267 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4268 }
4269 }
4270
4271
4272 502 void bmp_do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4273 {
4274 //sdci[1]=layer
4275 //sdci[2]=x
4276 //sdci[3]=y
4277 //sdci[4]=radiusx
4278 //sdci[5]=radiusy
4279 //sdci[6]=color
4280 //sdci[7]=scale factor
4281 //sdci[8]=rotation anchor x
4282 //sdci[9]=rotation anchor y
4283 //sdci[10]=rotation angle
4284 //sdci[11]=fill
4285 //sdci[12]=opacity
4286 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4287
4288
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if(sdci[7]==0) //scale
4289 {
4290 return;
4291 }
4292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 502 times.
502 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4293 {
4294 Z_scripterrlog("bitmap->Ellipse() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4295 return;
4296 }
4297 502 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4298
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if ( refbmp == NULL ) return;
4299
4300 502 int32_t x1=sdci[2]/10000;
4301 502 int32_t y1=sdci[3]/10000;
4302 502 int32_t radx=sdci[4]/10000;
4303 502 radx*=sdci[7]/10000;
4304 502 int32_t rady=sdci[5]/10000;
4305 502 rady*=sdci[7]/10000;
4306 502 int32_t color=sdci[6]/10000;
4307 502 float rotation = sdci[10]/10000;
4308
4309 502 int32_t rx=sdci[8]/10000;
4310 502 int32_t ry=sdci[9]/10000;
4311 502 fixed ra1=itofix(sdci[10]%10000)/10000;
4312 502 fixed ra2=itofix(sdci[10]/10000);
4313 502 fixed ra=ra1+ra2;
4314 502 ra = (ra/360)*256;
4315
4316
2/4
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 502 times.
✗ Branch 3 not taken.
502 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4317
4318 int32_t xy[2];
4319 502 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4320 502 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4321 502 x1=xy[0];
4322 502 y1=xy[1];
4323
4324
6/8
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 494 times.
502 if(radx<1||rady<1||radx>255||rady>255) return;
4325
4326 494 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
4327
4328
2/4
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 494 times.
494 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4329
4330
1/2
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
494 if(sdci[11]) //filled
4331 {
4332
4333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494 times.
494 if(sdci[12]/10000<128) //translucent
4334 {
4335 clear_bitmap(prim_bmp);
4336 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4337 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4338 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4339 }
4340 else // no opacity
4341 {
4342
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4343 494 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4344 }
4345 494 }
4346 else //not filled
4347 {
4348 if(sdci[12]/10000<128) //translucent
4349 {
4350 clear_bitmap(prim_bmp);
4351 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4352 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4353 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4354 }
4355 else // no opacity
4356 {
4357 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4358 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4359 }
4360 }
4361
4362 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
4363 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
4364 // the ellipse, but it shouldn't be used anyway.
4365
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 if(color==0)
4366 {
4367 // This is very slow, so check the smallest possible square
4368
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
4369
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
4370
4371
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 4430 times.
✓ Branch 7 taken 62 times.
4492 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
4372
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4430 times.
✓ Branch 2 taken 1086 times.
✓ Branch 3 taken 3344 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1086 times.
✓ Branch 6 taken 467774 times.
✓ Branch 7 taken 4430 times.
472204 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
4373
2/2
✓ Branch 0 taken 238992 times.
✓ Branch 1 taken 228782 times.
696556 if(getpixel(refbmp, x, y)==255)
4374 233212 putpixel(refbmp, x, y, 0);
4375 62 }
4376
4377 494 script_drawing_commands.ReleaseSubBitmap(bitty);
4378 502 }
4379
4380
4381 144 void bmp_do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4382 {
4383 //sdci[1]=layer
4384 //sdci[2]=x
4385 //sdci[3]=y
4386 //sdci[4]=x2
4387 //sdci[5]=y2
4388 //sdci[6]=color
4389 //sdci[7]=scale factor
4390 //sdci[8]=rotation anchor x
4391 //sdci[9]=rotation anchor y
4392 //sdci[10]=rotation angle
4393 //sdci[11]=opacity
4394 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4395
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7]==0) //scale
4396 {
4397 return;
4398 }
4399
4400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4401 {
4402 Z_scripterrlog("bitmap->Line() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4403 return;
4404 }
4405
4406 144 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4407
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if ( refbmp == NULL ) return;
4408
4409 144 int32_t x1=sdci[2]/10000;
4410 144 int32_t y1=sdci[3]/10000;
4411 144 int32_t x2=sdci[4]/10000;
4412 144 int32_t y2=sdci[5]/10000;
4413
4414
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7] != 10000)
4415 {
4416 int32_t w=x2-x1+1;
4417 int32_t h=y2-y1+1;
4418 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
4419 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
4420 x1=x1-((w2-w)/2);
4421 x2=x2+((w2-w)/2);
4422 y1=y1-((h2-h)/2);
4423 y2=y2+((h2-h)/2);
4424 }
4425
4426 144 int32_t color=sdci[6]/10000;
4427
4428
2/4
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
144 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4429
4430
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[11]/10000<=127) //translucent
4431 {
4432 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4433 }
4434
4435
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[10]!=0) //rotation
4436 {
4437 int32_t xy[4];
4438 int32_t rx=sdci[8]/10000;
4439 int32_t ry=sdci[9]/10000;
4440 fixed ra1=itofix(sdci[10]%10000)/10000;
4441 fixed ra2=itofix(sdci[10]/10000);
4442 fixed ra=ra1+ra2;
4443
4444 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4445 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4446 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
4447 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
4448 x1=xy[0];
4449 y1=xy[1];
4450 x2=xy[2];
4451 y2=xy[3];
4452 }
4453
4454 144 line(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
4455 144 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4456 144 }
4457
4458
4459 void bmp_do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4460 {
4461 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
4462 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4463
4464 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
4465 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
4466 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
4467 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
4468 };
4469
4470 if(sdci[11]/10000 < 128) //translucent
4471 {
4472 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4473 }
4474
4475 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4476 {
4477 Z_scripterrlog("bitmap->Spline() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4478 return;
4479 }
4480
4481 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4482 if ( refbmp == NULL ) return;
4483
4484 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4485
4486 spline(refbmp, points, sdci[10]/10000);
4487
4488 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4489 }
4490
4491
4492 80910 void bmp_do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4493 {
4494 //sdci[1]=layer
4495 //sdci[2]=x
4496 //sdci[3]=y
4497 //sdci[4]=color
4498 //sdci[5]=rotation anchor x
4499 //sdci[6]=rotation anchor y
4500 //sdci[7]=rotation angle
4501 //sdci[8]=opacity
4502 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4503 80910 int32_t x1=sdci[2]/10000;
4504 80910 int32_t y1=sdci[3]/10000;
4505 80910 int32_t color=sdci[4]/10000;
4506
4507
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if(sdci[8]/10000<=127) //translucent
4508 {
4509 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4510 }
4511
4512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4513 {
4514 Z_scripterrlog("bitmap->PutPixel() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4515 return;
4516 }
4517
4518 80910 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4519
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if ( refbmp == NULL ) return;
4520
4521
2/4
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80910 times.
✗ Branch 3 not taken.
80910 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4522
4523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if(sdci[7]!=0) //rotation
4524 {
4525 int32_t xy[2];
4526 int32_t rx=sdci[5]/10000;
4527 int32_t ry=sdci[6]/10000;
4528 fixed ra1=itofix(sdci[7]%10000)/10000;
4529 fixed ra2=itofix(sdci[7]/10000);
4530 fixed ra=ra1+ra2;
4531
4532 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4533 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4534 x1=xy[0];
4535 y1=xy[1];
4536 }
4537
4538 80910 putpixel(refbmp, x1+xoffset, y1+yoffset, color);
4539 80910 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4540 80910 }
4541
4542
4543 64994 void bmp_do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4544 {
4545 //sdci[1]=layer
4546 //sdci[2]=x
4547 //sdci[3]=y
4548 //sdci[4]=tile
4549 //sdci[5]=tile width
4550 //sdci[6]=tile height
4551 //sdci[7]=color (cset)
4552 //sdci[8]=scale x
4553 //sdci[9]=scale y
4554 //sdci[10]=rotation anchor x
4555 //sdci[11]=rotation anchor y
4556 //sdci[12]=rotation angle
4557 //sdci[13]=flip
4558 //sdci[14]=transparency
4559 //sdci[15]=opacity
4560 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4561
4562 64994 int32_t w = sdci[5]/10000;
4563 64994 int32_t h = sdci[6]/10000;
4564
4565
4/8
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64994 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64994 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64994 times.
64994 if(w < 1 || h < 1 || h > 20 || w > 20)
4566 {
4567 return;
4568 }
4569
4570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64994 times.
64994 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4571 {
4572 Z_scripterrlog("bitmap->DrawTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4573 return;
4574 }
4575
4576 64994 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64994 times.
64994 if ( refbmp == NULL ) return;
4578
4579 64994 int32_t xscale=sdci[8]/10000;
4580 64994 int32_t yscale=sdci[9]/10000;
4581 64994 int32_t rx = sdci[10]/10000;
4582 64994 int32_t ry = sdci[11]/10000;
4583 64994 float rotation=sdci[12]/10000;
4584 64994 int32_t flip=(sdci[13]/10000)&3;
4585 64994 bool transparency=sdci[14]!=0;
4586 64994 int32_t opacity=sdci[15]/10000;
4587 64994 int32_t color=sdci[7]/10000;
4588
4589 64994 int32_t x1=sdci[2]/10000;
4590 64994 int32_t y1=sdci[3]/10000;
4591
1/2
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
64994 byte skiprows = get_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY) ? 0 : h-1;
4592
4593
4594 //don't scale if it's not safe to do so
4595 64994 bool canscale = true;
4596
4597
2/4
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64994 times.
64994 if(xscale==0||yscale==0)
4598 {
4599 return;
4600 }
4601
4602
3/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 64088 times.
✓ Branch 2 taken 906 times.
✗ Branch 3 not taken.
64994 if(xscale<0||yscale<0)
4603 64088 canscale = false; //default size
4604
4605
2/4
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64994 times.
64994 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4606
4607
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 64088 times.
✓ Branch 2 taken 5644 times.
✓ Branch 3 taken 58444 times.
64994 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4608 {
4609 6550 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
4610
4611
1/2
✓ Branch 0 taken 6550 times.
✗ Branch 1 not taken.
6550 if(transparency) //transparency
4612 {
4613 6550 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip, skiprows);
4614 6550 }
4615 else //no transparency
4616 {
4617 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip, skiprows);
4618 }
4619
4620
2/2
✓ Branch 0 taken 5644 times.
✓ Branch 1 taken 906 times.
6550 if(rotation != 0)
4621 {
4622 //low negative values indicate no anchor-point rotation
4623
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5644 if(rx>-777||ry>-777)
4624 {
4625 int32_t xy[2];
4626 5644 fixed ra1=itofix(sdci[12]%10000)/10000;
4627 5644 fixed ra2=itofix(sdci[12]/10000);
4628 5644 fixed ra=ra1+ra2;
4629 5644 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4630 5644 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4631 5644 x1=xy[0];
4632 5644 y1=xy[1];
4633 5644 }
4634
4635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
5644 if(canscale) //scale first
4636 {
4637 //damnit all, .. fixme.
4638 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4639 clear_bitmap(tempbit);
4640
4641 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4642
4643 if(opacity < 128)
4644 {
4645 clear_bitmap(prim_bmp);
4646 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4647 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
4648 }
4649 else
4650 {
4651 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4652 }
4653
4654 destroy_bitmap(tempbit);
4655 }
4656 else //no scale
4657 {
4658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
5644 if(opacity < 128)
4659 {
4660 clear_bitmap(prim_bmp);
4661 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4662 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4663 }
4664 else
4665 {
4666 5644 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4667 }
4668 }
4669 5644 }
4670 else //scale only
4671 {
4672
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if(canscale)
4673 {
4674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(opacity<128)
4675 {
4676 clear_bitmap(prim_bmp);
4677 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4678 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4679 }
4680 else
4681 {
4682 906 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4683 }
4684 906 }
4685 else //error -do not scale
4686 {
4687 if(opacity<128)
4688 {
4689 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4690 }
4691 else
4692 {
4693 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4694 }
4695 }
4696 }
4697
4698 6550 script_drawing_commands.ReleaseSubBitmap(pbitty);
4699
4700 6550 }
4701 else // no scale or rotation
4702 {
4703
2/2
✓ Branch 0 taken 50106 times.
✓ Branch 1 taken 8338 times.
58444 if(transparency)
4704 {
4705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50106 times.
50106 if(opacity<=127)
4706 TileHelper::OverTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4707 else
4708 50106 TileHelper::OverTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4709 50106 }
4710 else
4711 {
4712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8338 times.
8338 if(opacity<=127)
4713 TileHelper::PutTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4714 else
4715 8338 TileHelper::OldPutTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4716 }
4717 }
4718 64994 }
4719
4720 void bmp_do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4721 {
4722 //sdci[1]=layer
4723 //sdci[2]=x
4724 //sdci[3]=y
4725 //sdci[4]=tile
4726 //sdci[5]=tile width
4727 //sdci[6]=tile height
4728 //sdci[7]=flip
4729 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4730
4731 int32_t w = sdci[5]/10000;
4732 int32_t h = sdci[6]/10000;
4733
4734 if(w < 1 || h < 1 || h > 20 || w > 20)
4735 {
4736 return;
4737 }
4738
4739 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4740 {
4741 Z_scripterrlog("bitmap->DrawTileCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4742 return;
4743 }
4744
4745 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4746 if ( refbmp == NULL ) return;
4747
4748 int32_t flip=(sdci[7]/10000)&3;
4749
4750 int32_t x1=sdci[2]/10000;
4751 int32_t y1=sdci[3]/10000;
4752 byte skiprows = get_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY) ? 0 : h-1;
4753
4754 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4755
4756 TileHelper::OverTileCloaked(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip, skiprows);
4757 }
4758
4759
4760 11288 void bmp_do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4761 {
4762 //sdci[1]=layer
4763 //sdci[2]=x
4764 //sdci[3]=y
4765 //sdci[4]=combo
4766 //sdci[5]=tile width
4767 //sdci[6]=tile height
4768 //sdci[7]=color (cset)
4769 //sdci[8]=scale x
4770 //sdci[9]=scale y
4771 //sdci[10]=rotation anchor x
4772 //sdci[11]=rotation anchor y
4773 //sdci[12]=rotation angle
4774 //sdci[13]=frame
4775 //sdci[14]=flip
4776 //sdci[15]=transparency
4777 //sdci[16]=opacity
4778 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4779 11288 int32_t w = sdci[5]/10000;
4780 11288 int32_t h = sdci[6]/10000;
4781
4782
4/8
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11288 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11288 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11288 times.
11288 if(w<1||h<1||h>20||w>20)
4783 {
4784 return;
4785 }
4786
4787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4788 {
4789 Z_scripterrlog("bitmap->DrawCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4790 return;
4791 }
4792
4793 11288 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4794
1/2
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
11288 if ( refbmp == NULL ) return;
4795 11288 int32_t cmb = (sdci[4]/10000);
4796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if((unsigned)cmb >= MAXCOMBOS)
4797 {
4798 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4799 return;
4800 }
4801
4802 11288 int32_t xscale=sdci[8]/10000;
4803 11288 int32_t yscale=sdci[9]/10000;
4804 11288 int32_t rx = sdci[10]/10000; //these work now
4805 11288 int32_t ry = sdci[11]/10000; //these work now
4806 11288 float rotation=sdci[12]/10000;
4807
4808 11288 bool transparency=sdci[15]!=0;
4809 11288 int32_t opacity=sdci[16]/10000;
4810 11288 int32_t color=sdci[7]/10000;
4811 11288 int32_t x1=sdci[2]/10000;
4812 11288 int32_t y1=sdci[3]/10000;
4813
4814 11288 auto& c = GET_DRAWING_COMBO(cmb);
4815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if(c.animflags & AF_EDITOR_ONLY) return;
4816 11288 int frame = sdci[13] / 10000;
4817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if (get_qr(qr_DRAWCOMBO_IGNORES_FRAME))
4818 11288 frame = -1;
4819 11288 int32_t tiletodraw = combo_tile(c, x1, y1, frame);
4820
4821 11288 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
4822 11288 int32_t skiprows=c.skipanimy;
4823
4824
4825 //don't scale if it's not safe to do so
4826 11288 bool canscale = true;
4827
4828
2/4
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if(xscale==0||yscale==0)
4829 {
4830 return;
4831 }
4832
4833
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11288 if(xscale<0||yscale<0)
4834 11288 canscale = false; //default size
4835
4836
2/4
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4837
4838
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4839 {
4840 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
4841
4842 if(transparency)
4843 {
4844 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4845 }
4846 else //no transparency
4847 {
4848 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4849 }
4850
4851 if(rotation != 0) // rotate
4852 {
4853 //fixed point sucks ;0
4854 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
4855 {
4856 int32_t xy[2];
4857 fixed ra1=itofix(sdci[12]%10000)/10000;
4858 fixed ra2=itofix(sdci[12]/10000);
4859 fixed ra=ra1+ra2;
4860 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4861 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4862 x1=xy[0];
4863 y1=xy[1];
4864 }
4865
4866 if(canscale) //scale first
4867 {
4868 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4869 clear_bitmap(tempbit);
4870
4871 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4872
4873 if(opacity < 128)
4874 {
4875 clear_bitmap(prim_bmp);
4876 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4877 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4878 }
4879 else
4880 {
4881 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4882 }
4883
4884 destroy_bitmap(tempbit);
4885 }
4886 else //no scale
4887 {
4888 if(opacity < 128)
4889 {
4890 clear_bitmap(prim_bmp);
4891 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4892 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4893 }
4894 else
4895 {
4896 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4897 }
4898 }
4899 }
4900 else //scale only
4901 {
4902 if(canscale)
4903 {
4904 if(opacity<128)
4905 {
4906 clear_bitmap(prim_bmp);
4907 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4908 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4909 }
4910 else
4911 {
4912 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4913 }
4914 }
4915 else //error -do not scale
4916 {
4917 if(opacity<128)
4918 {
4919 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4920 }
4921 else
4922 {
4923 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4924 }
4925 }
4926 }
4927
4928 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
4929 }
4930 else // no scale or rotation
4931 {
4932
1/2
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
11288 if(transparency)
4933 {
4934
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 11006 times.
11288 if(opacity<=127)
4935 282 TileHelper::OverTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4936 else
4937 11006 TileHelper::OverTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4938 11288 }
4939 else
4940 {
4941 if(opacity<=127)
4942 TileHelper::PutTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4943 else
4944 TileHelper::OldPutTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4945 }
4946 }
4947 11288 }
4948
4949
4950 void bmp_do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4951 {
4952 //sdci[1]=layer
4953 //sdci[2]=x
4954 //sdci[3]=y
4955 //sdci[4]=combo
4956 //sdci[5]=tile width
4957 //sdci[6]=tile height
4958 //sdci[7]=flip
4959 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4960
4961 int32_t w = sdci[5]/10000;
4962 int32_t h = sdci[6]/10000;
4963
4964 if(w<1||h<1||h>20||w>20)
4965 {
4966 return;
4967 }
4968
4969 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4970 {
4971 Z_scripterrlog("bitmap->DrawComboCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4972 return;
4973 }
4974
4975 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4976 if ( refbmp == NULL ) return;
4977 int32_t cmb = (sdci[4]/10000);
4978 if((unsigned)cmb >= MAXCOMBOS)
4979 {
4980 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4981 return;
4982 }
4983
4984 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4985
4986 int32_t x1=sdci[2]/10000;
4987 int32_t y1=sdci[3]/10000;
4988
4989 auto& c = GET_DRAWING_COMBO(cmb);
4990 if(c.animflags & AF_EDITOR_ONLY) return;
4991 int32_t tiletodraw = combo_tile(c, x1, y1);
4992 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
4993 int32_t skiprows=c.skipanimy;
4994
4995 TileHelper::OverTileCloaked(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
4996 }
4997
4998
4999 1982263 void bmp_do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5000 {
5001 /* layer, x, y, tile, color opacity */
5002 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5003
5004 1982263 int32_t opacity = sdci[6]/10000;
5005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1982263 times.
1982263 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5006 {
5007 Z_scripterrlog("bitmap->FastTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5008 return;
5009 }
5010 1982263 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5011
1/2
✓ Branch 0 taken 1982263 times.
✗ Branch 1 not taken.
1982263 if ( refbmp == NULL ) return;
5012
5013
2/4
✓ Branch 0 taken 1982263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1982263 times.
✗ Branch 3 not taken.
1982263 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5014
5015 1982263 int x = xoffset+(sdci[2]/10000);
5016 1982263 int y = yoffset+(sdci[3]/10000);
5017
5018
2/2
✓ Branch 0 taken 29119 times.
✓ Branch 1 taken 1953144 times.
1982263 if(opacity < 128)
5019 29119 overtiletranslucent16(refbmp, sdci[4]/10000, x, y, sdci[5]/10000, 0, opacity);
5020 else
5021 1953144 overtile16(refbmp, sdci[4]/10000, x, y, sdci[5]/10000, 0);
5022 1982263 }
5023
5024 19821648 void do_bmpwritetile(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5025 {
5026 /* layer, x, y, tile, is8bit, mask */
5027 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19821648 times.
19821648 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5029 {
5030 Z_scripterrlog("bitmap->WriteTile() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5031 return;
5032 }
5033 19821648 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5034
1/2
✓ Branch 0 taken 19821648 times.
✗ Branch 1 not taken.
19821648 if ( refbmp == NULL ) return;
5035
5036
2/4
✓ Branch 0 taken 19821648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19821648 times.
✗ Branch 3 not taken.
19821648 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5037
5038 19821648 int32_t x = (sdci[2]/10000), y = (sdci[3]/10000), tl = (sdci[4]/10000);
5039 19821648 bool is8bit = sdci[5]!=0, mask = sdci[6]!=0;
5040
5041 19821648 write_tile(newtilebuf, refbmp, tl, x+xoffset, y+yoffset, is8bit, mask);
5042 19821648 }
5043
5044 void do_bmpdither(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5045 {
5046 /* layer, mask, color, ditherType, ditherArg */
5047 //sdci[2] Mask Bitmap Pointer
5048 //sdci[3] Color
5049 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5050 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5051 {
5052 Z_scripterrlog("bitmap->Dither() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5053 return;
5054 }
5055 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5056 if ( refbmp == NULL ) return;
5057 if ( sdci[2] <= 0 )
5058 {
5059 Z_scripterrlog("bitmap->Dither() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5060 return;
5061 }
5062 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5063 if ( mask == NULL ) return;
5064
5065 int32_t dType = sdci[4] / 10000L;
5066 if(dType < 0 || dType >= dithMax)
5067 {
5068 Z_scripterrlog("bitmap->Dither() used an invalid dither type: %d. Aborting.\n", dType);
5069 return;
5070 }
5071
5072 ditherblit(refbmp, mask, byte(sdci[3]/10000L), dType, sdci[5]/10000L);
5073 }
5074
5075 7323 void do_bmpreplcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5076 {
5077 /* layer, shift, startcol, endcol */
5078 //sdci[2] NewCol
5079 //sdci[3] StartCol
5080 //sdci[4] EndCol
5081 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7323 times.
7323 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5083 {
5084 Z_scripterrlog("bitmap->ReplaceColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5085 return;
5086 }
5087 7323 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7323 times.
7323 if ( refbmp == NULL ) return;
5089 7323 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, false);
5090 7323 }
5091
5092 void do_bmpshiftcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5093 {
5094 /* layer, shift, startcol, endcol */
5095 //sdci[2] ShiftAmount
5096 //sdci[3] StartCol
5097 //sdci[4] EndCol
5098 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5099 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5100 {
5101 Z_scripterrlog("bitmap->ShiftColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5102 return;
5103 }
5104 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5105 if ( refbmp == NULL ) return;
5106 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, true);
5107 }
5108
5109 906 void do_bmpmaskdraw(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5110 {
5111 /* layer, mask, color */
5112 //sdci[2] Mask Bitmap Pointer
5113 //sdci[3] Color
5114 //sdci[4] start mask color
5115 //sdci[5] end mask color
5116 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5117 906 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5118
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( refbmp == NULL )
5119 {
5120 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5121 return;
5122 }
5123 906 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5124
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( mask == NULL )
5125 {
5126 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5127 return;
5128 }
5129 906 auto fillcol = sdci[3]/10000L;
5130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(unsigned(fillcol) > 0xFF) return; //invalid color, nothing to draw
5131 906 auto startcol = vbound(sdci[4]/10000L,0x00,0xFF);
5132 906 auto endcol = vbound(sdci[5]/10000L,0x00,0xFF);
5133 906 mask_colorfill(refbmp, mask, fillcol, startcol, endcol);
5134 906 }
5135
5136 void do_bmpmaskblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5137 {
5138 /* layer, mask, color */
5139 //sdci[2] Mask Bitmap Pointer
5140 //sdci[3] Pattern Bitmap
5141 //sdci[4] bool 'pattern repeats'
5142 //sdci[5] start mask color
5143 //sdci[6] end mask color
5144 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5145 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5146 if ( refbmp == NULL )
5147 {
5148 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5149 return;
5150 }
5151 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5152 if ( mask == NULL )
5153 {
5154 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (mask) id: %d. Aborting.\n", sdci[2]);
5155 return;
5156 }
5157 BITMAP *pattern = resolveScriptingBitmap(sdci[3]);
5158 if ( pattern == NULL )
5159 {
5160 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (pattern) id: %d. Aborting.\n", sdci[3]);
5161 return;
5162 }
5163 bool repeats = sdci[4]!=0;
5164 auto startcol = vbound(sdci[5]/10000L,0x00,0xFF);
5165 auto endcol = vbound(sdci[6]/10000L,0x00,0xFF);
5166 mask_blit(refbmp, mask, pattern, repeats, startcol, endcol);
5167 }
5168
5169 41542691 void bmp_do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5170 {
5171 /* layer, x, y, tile, color opacity */
5172 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5173 41542691 int32_t opacity = sdci[6] / 10000;
5174 41542691 int32_t x1 = sdci[2] / 10000;
5175 41542691 int32_t y1 = sdci[3] / 10000;
5176 41542691 int32_t index = sdci[4]/10000;
5177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41542691 times.
41542691 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5178 {
5179 Z_scripterrlog("bitmap->FastCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5180 return;
5181 }
5182 41542691 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5183
1/2
✓ Branch 0 taken 41542691 times.
✗ Branch 1 not taken.
41542691 if ( refbmp == NULL ) return;
5184 41542691 int32_t cmb = (sdci[4]/10000);
5185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41542691 times.
41542691 if((unsigned)cmb >= MAXCOMBOS)
5186 {
5187 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
5188 return;
5189 }
5190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41542691 times.
41542691 if(combobuf[cmb].animflags & AF_EDITOR_ONLY) return;
5191
5192
2/4
✓ Branch 0 taken 41542691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41542691 times.
✗ Branch 3 not taken.
41542691 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5193
5194 41542691 int x = xoffset+x1;
5195 41542691 int y = yoffset+y1;
5196
5197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41542691 times.
41542691 if(opacity < 128)
5198 {
5199 overcomboblocktranslucent(refbmp, x, y, cmb, sdci[5]/10000, 1, 1, 128);
5200
5201 }
5202 else
5203 {
5204 41542691 overcomboblock(refbmp, x, y, cmb, sdci[5]/10000, 1, 1);
5205 }
5206 41542691 }
5207
5208
5209
5210 void bmp_do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5211 {
5212 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5213 {
5214 Z_scripterrlog("bitmap->DrawCharacter() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5215 return;
5216 }
5217 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5218 if ( refbmp == NULL ) return;
5219
5220 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5221
5222 //broken 2.50.2 and earlier drawcharacter()
5223 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5224 {
5225 //sdci[1]=layer
5226 //sdci[2]=x
5227 //sdci[3]=y
5228 //sdci[4]=font
5229 //sdci[5]=color
5230 //sdci[6]=bg color
5231 //sdci[7]=strech x (width)
5232 //sdci[8]=stretch y (height)
5233 //sdci[9]=char
5234 //sdci[10]=opacity
5235 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5236
5237 int32_t x=sdci[2]/10000;
5238 int32_t y=sdci[3]/10000;
5239 int32_t font_index=sdci[4]/10000;
5240 int32_t color=sdci[5]/10000;
5241 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5242 int32_t w=sdci[7]/10000;
5243 int32_t h=sdci[8]/10000;
5244 char glyph=char(sdci[9]/10000);
5245 int32_t opacity=sdci[10]/10000;
5246
5247 //safe check
5248 if(bg_color < -1) bg_color = -1;
5249
5250 if(w>512) w=512; //w=vbound(w,0,512);
5251
5252 if(h>512) h=512; //h=vbound(h,0,512);
5253
5254 //undone
5255 if(w>0&&h>0)//stretch the character
5256 {
5257 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5258
5259 if(opacity < 128)
5260 {
5261 if(w>128||h>128)
5262 {
5263 clear_bitmap(prim_bmp);
5264
5265 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5266 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5267 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5268 }
5269 else //this is faster
5270 {
5271 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5272
5273 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5274 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5275 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5276
5277 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5278 }
5279 }
5280 else // no opacity
5281 {
5282 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5283 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5284 }
5285
5286 }
5287 else //no stretch
5288 {
5289 if(opacity < 128)
5290 {
5291 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5292 clear_bitmap(pbmp);
5293
5294 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5295 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5296
5297 destroy_bitmap(pbmp);
5298 }
5299 else // no opacity
5300 {
5301 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5302 }
5303 }
5304 }
5305
5306 else //2.53.0 fixed version and later.
5307 {
5308
5309 //sdci[1]=layer
5310 //sdci[2]=x
5311 //sdci[3]=y
5312 //sdci[4]=font
5313 //sdci[5]=color
5314 //sdci[6]=bg color
5315 //sdci[7]=strech x (width)
5316 //sdci[8]=stretch y (height)
5317 //sdci[9]=char
5318 //sdci[10]=opacity
5319
5320 int32_t x=sdci[2]/10000;
5321 int32_t y=sdci[3]/10000;
5322 int32_t font_index=sdci[4]/10000;
5323 int32_t color=sdci[5]/10000;
5324 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5325 int32_t w=sdci[7]/10000;
5326 int32_t h=sdci[8]/10000;
5327 char glyph=char(sdci[9]/10000);
5328 int32_t opacity=sdci[10]/10000;
5329
5330 //safe check
5331 if(bg_color < -1) bg_color = -1;
5332
5333 if(w>512) w=512; //w=vbound(w,0,512);
5334
5335 if(h>512) h=512; //h=vbound(h,0,512);
5336
5337 //undone
5338 if(w>0&&h>0)//stretch the character
5339 {
5340 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5341
5342 if(opacity < 128)
5343 {
5344 if(w>128||h>128)
5345 {
5346 clear_bitmap(prim_bmp);
5347
5348 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5349 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5350 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5351 }
5352 else //this is faster
5353 {
5354 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5355
5356 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5357 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5358 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5359
5360 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5361 }
5362 }
5363 else // no opacity
5364 {
5365 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5366 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5367 }
5368
5369 }
5370 else //no stretch
5371 {
5372 if(opacity < 128)
5373 {
5374 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5375 clear_bitmap(pbmp);
5376
5377 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5378 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5379
5380 destroy_bitmap(pbmp);
5381 }
5382 else // no opacity
5383 {
5384 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5385 }
5386 }
5387
5388 }
5389
5390 }
5391
5392
5393 void bmp_do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5394 {
5395 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5396 {
5397 Z_scripterrlog("bitmap->DrawInteger() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5398 return;
5399 }
5400 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5401 if ( refbmp == NULL ) return;
5402
5403 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5404
5405 //broken 2.50.2 and earlier drawinteger()
5406 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5407 {
5408 //sdci[1]=layer
5409 //sdci[2]=x
5410 //sdci[3]=y
5411 //sdci[4]=font
5412 //sdci[5]=color
5413 //sdci[6]=bg color
5414 //sdci[7]=strech x (width)
5415 //sdci[8]=stretch y (height)
5416 //sdci[9]=integer
5417 //sdci[10]=num decimal places
5418 //sdci[11]=opacity
5419 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5420
5421 int32_t x=sdci[2]/10000;
5422 int32_t y=sdci[3]/10000;
5423 int32_t font_index=sdci[4]/10000;
5424 int32_t color=sdci[5]/10000;
5425 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5426 int32_t w=sdci[7]/10000;
5427 int32_t h=sdci[8]/10000;
5428 int32_t decplace=sdci[10]/10000;
5429 int32_t opacity=sdci[11]/10000;
5430
5431 //safe check
5432 if(bg_color < -1) bg_color = -1;
5433
5434 if(w>512) w=512; //w=vbound(w,0,512);
5435
5436 if(h>512) h=512; //h=vbound(h,0,512);
5437
5438 char numbuf[15];
5439
5440 switch(decplace)
5441 {
5442 default:
5443 case 0:
5444 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5445 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5446
5447 case 1:
5448 //sprintf(numbuf,"%.01f",number);
5449 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5450 break;
5451
5452 case 2:
5453 //sprintf(numbuf,"%.02f",number);
5454 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5455 break;
5456
5457 case 3:
5458 //sprintf(numbuf,"%.03f",number);
5459 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5460 break;
5461
5462 case 4:
5463 //sprintf(numbuf,"%.04f",number);
5464 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5465 break;
5466 }
5467
5468 if(w>0&&h>0)//stretch
5469 {
5470 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5471
5472 if(opacity < 128)
5473 {
5474 if(w>128||h>128)
5475 {
5476 clear_bitmap(prim_bmp);
5477
5478 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5479 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5480 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5481 }
5482 else
5483 {
5484 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5485 clear_bitmap(pbmp2);
5486
5487 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5488 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5489 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5490
5491 destroy_bitmap(pbmp2);
5492 }
5493 }
5494 else // no opacity
5495 {
5496 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5497 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5498 }
5499
5500 }
5501 else //no stretch
5502 {
5503 if(opacity < 128)
5504 {
5505 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5506 clear_bitmap(pbmp);
5507
5508 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5509 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5510
5511 destroy_bitmap(pbmp);
5512 }
5513 else // no opacity
5514 {
5515 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5516 }
5517 }
5518
5519 }
5520
5521 else //2.53.0 fixed version and later.
5522 {
5523 //sdci[1]=layer
5524 //sdci[2]=x
5525 //sdci[3]=y
5526 //sdci[4]=font
5527 //sdci[5]=color
5528 //sdci[6]=bg color
5529 //sdci[7]=strech x (width)
5530 //sdci[8]=stretch y (height)
5531 //sdci[9]=integer
5532 //sdci[10]=num decimal places
5533 //sdci[11]=opacity
5534
5535 int32_t x=sdci[2]/10000;
5536 int32_t y=sdci[3]/10000;
5537 int32_t font_index=sdci[4]/10000;
5538 int32_t color=sdci[5]/10000;
5539 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5540 int32_t w=sdci[7]/10000;
5541 int32_t h=sdci[8]/10000;
5542 int32_t decplace=sdci[10]/10000;
5543 int32_t opacity=sdci[11]/10000;
5544
5545 //safe check
5546 if(bg_color < -1) bg_color = -1;
5547
5548 if(w>512) w=512; //w=vbound(w,0,512);
5549
5550 if(h>512) h=512; //h=vbound(h,0,512);
5551
5552 char numbuf[15];
5553
5554 switch(decplace)
5555 {
5556 default:
5557 case 0:
5558 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5559 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5560
5561 case 1:
5562 //sprintf(numbuf,"%.01f",number);
5563 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5564 break;
5565
5566 case 2:
5567 //sprintf(numbuf,"%.02f",number);
5568 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5569 break;
5570
5571 case 3:
5572 //sprintf(numbuf,"%.03f",number);
5573 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5574 break;
5575
5576 case 4:
5577 //sprintf(numbuf,"%.04f",number);
5578 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5579 break;
5580 }
5581
5582 //FONT* font=get_zc_font(sdci[4]/10000);
5583
5584 if(w>0&&h>0)//stretch
5585 {
5586 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
5587 clear_bitmap(pbmp);
5588 //script_drawing_commands.GetSmallTextureBitmap(1,1);
5589
5590 if(opacity < 128)
5591 {
5592 if(w>128||h>128)
5593 {
5594 clear_bitmap(prim_bmp);
5595
5596 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5597 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5598 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5599 }
5600 else
5601 {
5602 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5603 clear_bitmap(pbmp2);
5604
5605 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5606 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5607 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5608
5609 destroy_bitmap(pbmp2);
5610 }
5611 }
5612 else // no opacity
5613 {
5614 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5615 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5616 }
5617
5618 }
5619 else //no stretch
5620 {
5621 if(opacity < 128)
5622 {
5623 FONT* font = get_zc_font(font_index);
5624 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
5625 clear_bitmap(pbmp);
5626
5627 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
5628 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5629
5630 destroy_bitmap(pbmp);
5631 }
5632 else // no opacity
5633 {
5634 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5635 }
5636 }
5637 }
5638 }
5639
5640
5641 865 void bmp_do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5642 {
5643 //sdci[1]=layer
5644 //sdci[2]=x
5645 //sdci[3]=y
5646 //sdci[4]=font
5647 //sdci[5]=color
5648 //sdci[6]=bg color
5649 //sdci[7]=format_option
5650 //sdci[8]=string
5651 //sdci[9]=opacity
5652 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5654 {
5655 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5656 return;
5657 }
5658
5659 865 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5660
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if ( refbmp == NULL ) return;
5661
5662
2/4
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 865 times.
865 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5663
5664 865 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5665
5666
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if(!str)
5667 {
5668 al_trace("String pointer is null! Internal error. \n");
5669 return;
5670 }
5671
5672 865 int32_t x=sdci[2]/10000;
5673 865 int32_t y=sdci[3]/10000;
5674 865 FONT* font=get_zc_font(sdci[4]/10000);
5675 865 int32_t color=sdci[5]/10000;
5676 865 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5677 865 int32_t format_type=sdci[7]/10000;
5678 865 int32_t opacity=sdci[9]/10000;
5679 //sdci[8] not needed :)
5680
5681 //safe check
5682
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if(bg_color < -1) bg_color = -1;
5683
5684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(opacity < 128)
5685 {
5686 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5687 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5688 clear_bitmap(pbmp);
5689 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
5690 if(format_type == 2) // right-sided text
5691 x-=width;
5692 else if(format_type == 1) // centered text
5693 x-=width/2;
5694 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5695 destroy_bitmap(pbmp);
5696 }
5697 else // no opacity
5698 {
5699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(format_type == 2) // right-sided text
5700 {
5701 textout_right_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5702 }
5703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if(format_type == 1) // centered text
5704 {
5705 textout_centre_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5706 }
5707 else // standard left-sided text
5708 {
5709 865 textout_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5710 }
5711 }
5712 865 }
5713
5714 45504 void bmp_do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5715 {
5716 //sdci[1]=layer
5717 //sdci[2]=x
5718 //sdci[3]=y
5719 //sdci[4]=font
5720 //sdci[5]=color
5721 //sdci[6]=bg color
5722 //sdci[7]=format_option
5723 //sdci[8]=string
5724 //sdci[9]=opacity
5725 //sdci[10]=shadowtype
5726 //sdci[11]=shadow_color
5727 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5729 {
5730 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5731 return;
5732 }
5733
5734 45504 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5735
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if ( refbmp == NULL ) return;
5736
5737
2/4
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45504 times.
45504 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5738
5739 45504 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5740
5741
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(!str)
5742 {
5743 al_trace("String pointer is null! Internal error. \n");
5744 return;
5745 }
5746
5747 45504 int32_t x=sdci[2]/10000;
5748 45504 int32_t y=sdci[3]/10000;
5749 45504 FONT* font=get_zc_font(sdci[4]/10000);
5750 45504 int32_t color=sdci[5]/10000;
5751 45504 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5752 45504 int32_t format_type=sdci[7]/10000;
5753 45504 int32_t opacity=sdci[9]/10000;
5754 45504 int32_t textstyle = sdci[10]/10000;
5755 45504 int32_t shadow_color = sdci[11]/10000;
5756 //sdci[8] not needed :)
5757
5758 //safe check
5759
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(bg_color < -1) bg_color = -1;
5760
5761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if(opacity < 128)
5762 {
5763 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5764 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5765 clear_bitmap(pbmp);
5766 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, ALIGN_LEFT, color, shadow_color, bg_color);
5767 if(format_type == 2) // right-sided text
5768 x-=width;
5769 else if(format_type == 1) // centered text
5770 x-=width/2;
5771 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5772 destroy_bitmap(pbmp);
5773 }
5774 else // no opacity
5775 {
5776 45504 textout_styled_aligned_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
5777 }
5778 45504 }
5779
5780 2134433 void bmp_do_clearr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5781 {
5782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2134433 times.
2134433 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5783 {
5784 Z_scripterrlog("bitmap->Clear() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5785 return;
5786 }
5787
5788 2134433 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2134433 times.
2134433 if ( !refbmp ) return;
5790
5791 2134433 clear_bitmap(refbmp);
5792 2134433 }
5793
5794 34749 void bmp_do_clearcolorr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5795 {
5796 //sdci[1]=layer
5797 //sdci[2]=color
5798 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5799 34749 int32_t pal_color = sdci[2]/10000;
5800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34749 times.
34749 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5801 {
5802 Z_scripterrlog("bitmap->ClearToColor() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5803 return;
5804 }
5805
5806 34749 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34749 times.
34749 if ( !refbmp ) return;
5808
5809 34749 clear_to_color(refbmp, pal_color);
5810 34749 }
5811
5812
5813 43007 void bmp_do_regenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5814 {
5815 //sdci[1]=layer
5816 43007 int32_t h = sdci[3]/10000;
5817 43007 int32_t w = sdci[2]/10000;
5818
1/2
✓ Branch 0 taken 43007 times.
✗ Branch 1 not taken.
43007 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
5819 {
5820 //flip height and width
5821 h = h ^ w;
5822 w = h ^ w;
5823 h = h ^ w;
5824 }
5825 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5826 //Z_scripterrlog("bitmap->Create() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43007 times.
43007 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5828 {
5829 Z_scripterrlog("bitmap->Create() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5830 return;
5831 }
5832 43007 int32_t bitid = sdci[DRAWCMD_BMP_TARGET];
5833 43007 auto& usr_bmp = scb.get(bitid);
5834
2/2
✓ Branch 0 taken 42757 times.
✓ Branch 1 taken 250 times.
43007 if ( usr_bmp.u_bmp )
5835 42757 destroy_bitmap(usr_bmp.u_bmp);
5836 43007 usr_bmp.u_bmp = create_bitmap_ex(8,w,h);
5837
5838 43007 usr_bmp.width = w;
5839 43007 usr_bmp.height = h;
5840 43007 }
5841
5842 void bmp_do_readr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5843 {
5844 //sdci[1]=layer
5845 //sdci[2]=filename
5846 //sdci[3]=y
5847 //sdci[4]=font
5848 //sdci[5]=color
5849 //sdci[6]=bg color
5850 //sdci[7]=format_option
5851 //sdci[8]=string
5852 //sdci[9]=opacity
5853 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5854 //Z_scripterrlog("bitmap->Read() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5855 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5856 {
5857 Z_scripterrlog("bitmap->Read() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5858 return;
5859 }
5860 int32_t bitid = sdci[DRAWCMD_BMP_TARGET];
5861 auto& usr_bitmap = scb.get(bitid);
5862 usr_bitmap.destroy();
5863
5864 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5865
5866 if(!str)
5867 {
5868 al_trace("String pointer is null! Internal error. \n");
5869 return;
5870 }
5871
5872 PALETTE tempPal;
5873 get_palette(tempPal);
5874 if ( checkPath(str->c_str(), false) )
5875 {
5876 usr_bitmap.u_bmp = load_bitmap(str->c_str(), tempPal);
5877 usr_bitmap.width = usr_bitmap.u_bmp->w;
5878 usr_bitmap.height = usr_bitmap.u_bmp->h;
5879 if ( !usr_bitmap.u_bmp )
5880 {
5881 Z_scripterrlog("Failed to load image file %s.\nMaking a blank bitmap on the pointer.\n", str->c_str());
5882 }
5883 else
5884 {
5885 zprint("Read image file %s\n",str->c_str());
5886 }
5887 }
5888 else
5889 {
5890 Z_scripterrlog("Failed to load image file: %s. File not found. Creating a blank bitmap on the pointer.\n", str->c_str());
5891 usr_bitmap.u_bmp = create_bitmap_ex(8,256,176);
5892 clear_bitmap(usr_bitmap.u_bmp);
5893 }
5894 }
5895
5896
5897
5898 void bmp_do_writer(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5899 {
5900 //sdci[1]=layer
5901 //sdci[2]=filename
5902 //sdci[3]=y
5903 //sdci[4]=font
5904 //sdci[5]=color
5905 //sdci[6]=bg color
5906 //sdci[7]=format_option
5907 //sdci[8]=string
5908 //sdci[9]=opacity
5909 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5910 //Z_scripterrlog("bitmap->Write() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5911
5912 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5913 {
5914 Z_scripterrlog("bitmap->Write() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5915 return;
5916 }
5917
5918 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5919 if ( !refbmp ) return;
5920
5921 bool overwrite = (sdci[3] != 0);
5922 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5923
5924 if(!str)
5925 {
5926 al_trace("String pointer is null! Internal error. \n");
5927 return;
5928 }
5929
5930 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
5931 //std::strncpy(cptr, str->c_str(), str->size());
5932 //Z_scripterrlog("bitmap->Write extension matches ? : %s\n!", (FFCore.checkExtension(str->c_str(), ".png")) ? "true" : "false");
5933 //Z_scripterrlog("Trying to write filename %s\n", cptr);
5934 if
5935 (
5936 ( (FFCore.checkExtension(*str, "")) ) ||
5937 ( !(FFCore.checkExtension(*str, ".png")) && !(FFCore.checkExtension(*str, ".gif")) && !(FFCore.checkExtension(*str, ".bmp"))
5938 && !(FFCore.checkExtension(*str, ".pcx")) && !(FFCore.checkExtension(*str, ".tga")) )
5939 )
5940 {
5941 Z_scripterrlog("No extension, or invalid extension provided for writing bitmap file %s. Could not write the file.\nValid types are .png, .gif, .pcx, .tgx, and .bmp. Aborting.\n",str->c_str());
5942 }
5943 else if ( overwrite || (!checkPath(str->c_str(), false)) )
5944 {
5945 if(make_dirs_for_file(*str))
5946 {
5947 save_bitmap(str->c_str(), refbmp, RAMpal);
5948 if(checkPath(str->c_str(), false))
5949 {
5950 zprint("Wrote image file %s\n",str->c_str());
5951 }
5952 else
5953 {
5954 Z_scripterrlog("Failed to create file '%s'\n",str->c_str());
5955 }
5956 }
5957 else
5958 {
5959 Z_scripterrlog("Cannot write file '%s' because the directory does not exist, and could not be created.\n", str->c_str());
5960 }
5961 }
5962 else Z_scripterrlog("Cannot write file '%s' because the file already exists in the specified path.\n", str->c_str());
5963 }
5964
5965
5966 void bmp_do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5967 {
5968 //sdci[1]=layer
5969 //sdci[2]=x1
5970 //sdci[3]=y1
5971 //sdci[4]=x2
5972 //sdci[5]=y2
5973 //sdci[6]=x3
5974 //sdci[7]=y3
5975 //sdci[8]=x4
5976 //sdci[9]=y4
5977 //sdci[10]=width
5978 //sdci[11]=height
5979 //sdci[12]=cset
5980 //sdci[13]=flip
5981 //sdci[14]=tile/combo
5982 //sdci[15]=polytype
5983 //sdci[16] = other bitmap as texture
5984 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5985 Z_scripterrlog("bitmap quad pointer: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5986 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5987 {
5988 Z_scripterrlog("bitmap->Quad() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5989 return;
5990 }
5991 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5992
5993 if ( !refbmp ) return;
5994
5995 int32_t x1 = sdci[2]/10000;
5996 int32_t y1 = sdci[3]/10000;
5997 int32_t x2 = sdci[4]/10000;
5998 int32_t y2 = sdci[5]/10000;
5999 int32_t x3 = sdci[6]/10000;
6000 int32_t y3 = sdci[7]/10000;
6001 int32_t x4 = sdci[8]/10000;
6002 int32_t y4 = sdci[9]/10000;
6003 int32_t w = sdci[10]/10000;
6004 int32_t h = sdci[11]/10000;
6005 int32_t color = sdci[12]/10000;
6006 int32_t flip=(sdci[13]/10000)&3;
6007 int32_t tile = sdci[14]/10000;
6008 int32_t polytype = sdci[15]/10000;
6009 int32_t quad_render_source = sdci[16];
6010 //Z_scripterrlog("bitmap->Quad() render source is: %d\n", quad_render_source);
6011
6012 bool tex_is_bitmap = ( sdci[16] != 0 );
6013
6014 BITMAP *bmptexture=NULL;
6015 BITMAP *tex=NULL;
6016 polytype = vbound(polytype, 0, 14);
6017
6018 int32_t col[4];
6019 col[0]=col[1]=col[2]=col[3]=color;
6020 bool mustDestroyBmp = false;
6021
6022 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6023
6024 if ( tex_is_bitmap )
6025 {
6026 bmptexture = resolveScriptingBitmap(quad_render_source);
6027 if ( !bmptexture )
6028 {
6029 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6030 tex_is_bitmap = 0;
6031 }
6032 }
6033
6034 if ( tex_is_bitmap )
6035 {
6036
6037 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6038 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6039 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", w);
6040 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", h);
6041
6042 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6043 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6044 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6045 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6046
6047 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
6048 }
6049 else
6050 {
6051 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6052 if(!tex)
6053 {
6054 //Z_scripterrlog("Bitmap->Quad() found an invalid texture bitmap.\n");
6055 mustDestroyBmp = true;
6056 tex = create_bitmap_ex(8, w*16, h*16);
6057 clear_bitmap(tex);
6058 }
6059
6060 if(tile > 0) // TILE
6061 {
6062 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6063 }
6064
6065 if ( tile < 0 ) // COMBO
6066 {
6067 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
6068 const int32_t tiletodraw = combo_tile(c, x1, y1);
6069 flip = flip ^ c.flip;
6070
6071 if(!(c.animflags & AF_EDITOR_ONLY))
6072 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6073 }
6074 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6075 {
6076 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6077 return; //non power of two error
6078 }
6079 //Z_scripterrlog("bitmap->Quad() is trying to blit from a bitmap texture.\n");
6080 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6081 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6082 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6083 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6084
6085 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
6086
6087 }
6088
6089
6090
6091
6092 //todo: finish palette shading
6093 /*
6094 POLYTYPE_FLAT
6095 POLYTYPE_GCOL
6096 POLYTYPE_GRGB
6097 POLYTYPE_ATEX
6098 POLYTYPE_PTEX
6099 POLYTYPE_ATEX_MASK
6100 POLYTYPE_PTEX_MASK
6101 POLYTYPE_ATEX_LIT
6102 POLYTYPE_PTEX_LIT
6103 POLYTYPE_ATEX_MASK_LIT
6104 POLYTYPE_PTEX_MASK_LIT
6105 POLYTYPE_ATEX_TRANS
6106 POLYTYPE_PTEX_TRANS
6107 POLYTYPE_ATEX_MASK_TRANS
6108 POLYTYPE_PTEX_MASK_TRANS
6109 */
6110
6111 if(mustDestroyBmp)
6112 destroy_bitmap(tex);
6113
6114 }
6115
6116 void bmp_do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6117 {
6118 //sdci[1]=layer
6119 //sdci[2]=x1
6120 //sdci[3]=y1
6121 //sdci[4]=x2
6122 //sdci[5]=y2
6123 //sdci[6]=x3
6124 //sdci[7]=y3
6125 //sdci[8]=width
6126 //sdci[9]=height
6127 //sdci[10]=cset
6128 //sdci[11]=flip
6129 //sdci[12]=tile/combo
6130 //sdci[13]=polytype
6131 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6132 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
6133 {
6134 Z_scripterrlog("bitmap->Triangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
6135 return;
6136 }
6137 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
6138 if ( refbmp == NULL ) return;
6139
6140
6141 int32_t render_source = sdci[14];
6142 //Z_scripterrlog("bitmap->Triangle() render source is: %d\n", render_source);
6143
6144 bool tex_is_bitmap = ( sdci[14] != 0 );
6145
6146 BITMAP *bmptexture=NULL;
6147 if ( tex_is_bitmap )
6148 {
6149 bmptexture = resolveScriptingBitmap(render_source);
6150 if ( !bmptexture )
6151 {
6152 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6153 tex_is_bitmap = 0;
6154 }
6155 }
6156
6157 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6158
6159 int32_t x1 = sdci[2]/10000;
6160 int32_t y1 = sdci[3]/10000;
6161 int32_t x2 = sdci[4]/10000;
6162 int32_t y2 = sdci[5]/10000;
6163 int32_t x3 = sdci[6]/10000;
6164 int32_t y3 = sdci[7]/10000;
6165 int32_t w = sdci[8]/10000;
6166 int32_t h = sdci[9]/10000;
6167 int32_t color = sdci[10]/10000;
6168 int32_t flip=(sdci[11]/10000)&3;
6169 int32_t tile = sdci[12]/10000;
6170 int32_t polytype = sdci[13]/10000;
6171
6172 polytype = vbound(polytype, 0, 14);
6173 int32_t utex_w = w;
6174 int32_t utex_h = h;
6175
6176
6177 int32_t tex_width = w*16;
6178 int32_t tex_height = h*16;
6179
6180 bool mustDestroyBmp = false;
6181 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6182
6183 if(!tex)
6184 {
6185 mustDestroyBmp = true;
6186 tex = create_bitmap_ex(8, tex_width, tex_height);
6187 clear_bitmap(tex);
6188 }
6189
6190 int32_t col[3];
6191 /*
6192 if( color < 0 )
6193 {
6194 col[0]=draw_container.color_buffer[0];
6195 col[1]=draw_container.color_buffer[1];
6196 col[2]=draw_container.color_buffer[2];
6197 }
6198 else */
6199 {
6200 col[0]=col[1]=col[2]=color;
6201 }
6202
6203 if(tile > 0) // TILE
6204 {
6205 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6206 }
6207 else // COMBO
6208 {
6209 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
6210 const int32_t tiletodraw = combo_tile(c, x1, y1);
6211 flip = flip ^ c.flip;
6212
6213 if(!(c.animflags & AF_EDITOR_ONLY))
6214 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6215 }
6216 if ( !tex_is_bitmap )
6217 {
6218 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6219 {
6220 Z_message("bitmap->Triangle() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6221 return; //non power of two error
6222 }
6223 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6224 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
6225 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
6226
6227
6228 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
6229
6230 }
6231
6232 else
6233 {
6234 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6235 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6236 if ( !isPowerOfTwo(utex_h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_w);
6237 if ( !isPowerOfTwo(utex_w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_h);
6238
6239 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6240 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(utex_h), col[1] };
6241 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(utex_w), static_cast<float>(utex_h), col[2] };
6242
6243
6244 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
6245
6246 }
6247
6248 if(mustDestroyBmp)
6249 destroy_bitmap(tex);
6250 }
6251
6252
6253 void bmp_do_mode7r(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6254 {
6255 /*
6256 int32_t layer, int32_t rt, int32_t srcX, int32_t srcY, int32_t srcW, int32_t srcH, int32_t destW, int32_t destH, int32_t angle, int32_t cx, int32_t cy, int32_t space_z, int32_t horizon,
6257 int32_t scale_x, int32_t scale_y){
6258
6259 //sdci[1]=layer
6260 //sdci[2]=bitmap target
6261 //
6262 // -2 is the current Render Target
6263 // -1, this is the screen (framebuf).
6264 // 0: Render target 0
6265 // 1: Render target 1
6266 // 2: Render target 2
6267 // 3: Render target 3
6268 // 4: Render target 4
6269 // 5: Render target 5
6270 // 6: Render target 6
6271 // Otherwise: The pointer to a bitmap.
6272
6273 //sdci[3]=sourcex
6274 //sdci[4]=sourcey
6275 //sdci[5]=sourcew
6276 //sdci[6]=sourceh
6277
6278 //sdci[7]=destw
6279 //sdci[8]=desth
6280 //sdci[9]=angle
6281 //scdi[10] = pivot cx
6282 //sdci[11] = pivot cy
6283 //sdci[12] = space Z
6284 //sdci[13] = horizon
6285 //scdi[14] = scale X
6286 //scdi[15] = scale Y
6287 //sdci[16] = masked?
6288 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6289
6290
6291
6292 // ZScript-side constant values:
6293 const int32_t BITDX_NORMAL = 0;
6294 const int32_t BITDX_TRANS = 1; //Translucent
6295 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6296 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6297 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6298 //Note: Some modes cannot be combined. if a combination is not supported, an error
6299 // detailing this will be shown in allegro.log.
6300
6301 //scdi[15] = litcolour
6302 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6303 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6304
6305 //sdci[16]=mask
6306
6307 */
6308
6309
6310 int32_t bitmapIndex = sdci[2];
6311 int32_t usr_bitmap_index = sdci[2];
6312 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
6313 //Z_scripterrlog("DrawPlane() bitmapIndex is: %d\n", bitmapIndex);
6314
6315 if ( bitmapIndex >= 10000 )
6316 {
6317 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
6318 }
6319 else if ( usr_bitmap_index > 0 )
6320 {
6321 bitmapIndex = usr_bitmap_index;
6322 // Z_scripterrlog("Mode7 is using a user bitmap target, pointer: %d\n", usr_bitmap_index);
6323 yoffset = 0;
6324 }
6325
6326 //rendering mode 7 args
6327 double srcX = sdci[3]/10000.0;
6328 double srcY = sdci[4]/10000.0;
6329 double destX = sdci[5]/10000.0;
6330 double destY = sdci[6]/10000.0;
6331
6332 double destW = sdci[7]/10000.0;
6333 double destH = sdci[8]/10000.0;
6334 double space_z = sdci[9]/10000.0;
6335 double horizon = sdci[10]/10000.0;
6336 double scale_x = sdci[11]/10000.0;
6337 double scale_y = sdci[12]/10000.0;
6338 byte masked = ( sdci[13] ) ? 1 : 0;
6339
6340
6341 int32_t ref = 0;
6342
6343 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6344 //Do we need to also check the render target and do the same thing if the
6345 //dest == -2 and the render target is not RT_SCREEN?
6346
6347 ref = sdci[DRAWCMD_BMP_TARGET];
6348
6349
6350 if ( ref <= 0 )
6351 {
6352 Z_scripterrlog("bitmap->DrawPlane() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6353 return;
6354 }
6355 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
6356
6357 if(!sourceBitmap)
6358 {
6359 Z_message("Warning: %d->DrawPlane() source bitmap contains invalid data or is not initialized.\n", ref);
6360 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6361 return;
6362 }
6363
6364 BITMAP *destBMP=NULL;
6365 switch(bitmapIndex)
6366 {
6367 // Current render target (RT_CURRENT).
6368 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
6369 case -2:
6370 {
6371 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6372 if ( curr_rt >= 0 && curr_rt < 7 )
6373 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6374 else destBMP = bmp; //screen
6375 break;
6376 }
6377 case -1:
6378 destBMP = bmp; //this is framebuf, by default
6379 break;
6380
6381 //1 through 6 are the old system bitmaps (Render Targets)
6382 case 0:
6383 case 1:
6384 case 2:
6385 case 3:
6386 case 4:
6387 case 5:
6388 case 6:
6389 {
6390 //This gets a render target.
6391 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6392 break;
6393 }
6394 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6395 default:
6396 {
6397 auto& usr_bitmap = scb.get(usr_bitmap_index);
6398 destBMP = usr_bitmap.u_bmp;
6399 if ( !usr_bitmap.u_bmp )
6400 {
6401 Z_scripterrlog("Target for bitmap->DrawPlane is uninitialised. Aborting.\n");
6402 break;
6403 }
6404 }
6405 }
6406
6407 if (!destBMP)
6408 {
6409 Z_message("Warning: DrawPlane(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6410 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6411 return;
6412 }
6413
6414 //dx = dx + xoffset; //don't do this here!
6415 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6416 //All of these are a factor of 10000 as fix.
6417 int32_t screen_x = 0; int32_t screen_y = 0;
6418
6419 double distance = 0; double horizontal_scale = 0;
6420
6421 int32_t screen_y_horizon = 0;
6422
6423 double line_dx = 0; double line_dy = 0;
6424
6425 int32_t space_x = 0; int32_t space_y = 0;
6426
6427 for(screen_y = 0; screen_y < destH; screen_y++) //fix, offset by .0000
6428 {
6429 //Calculate the distance of each line from the camera point
6430 screen_y_horizon = screen_y + horizon;
6431
6432 distance = ((space_z * scale_y) / ((screen_y_horizon != 0) ? screen_y_horizon : 1));
6433
6434 //Get the scale of each line based on the distance
6435
6436 horizontal_scale = (distance / (( scale_x != 0 ) ? scale_x : 1));
6437
6438 //There was some math here before I stripped out the rotation step
6439 line_dx = horizontal_scale;
6440 line_dy = 0;
6441
6442 //space_x,space_y - where to grab each scanline from on the space bitmap
6443 space_x = srcX - destW/2.0 * line_dx;
6444 space_y = srcY - distance + destH/2.0 * line_dy;
6445
6446 //Keep blits within the bounds of both bitmaps to avoid crashes
6447 int32_t y1 = srcY+space_y;
6448 int32_t y2 = destY+screen_y;
6449 if(y1 >=0 && y1 <= (sourceBitmap->h-1) && y2 >=0 && y2 <= (destBMP->h-1) )
6450 {
6451 if ( masked ) masked_stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6452 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6453 else stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6454 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6455 }
6456 }
6457 }
6458
6459
6460 //Draw]()
6461 2062708 void bmp_do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6462 {
6463 /*
6464 //sdci[1]=layer
6465 //sdci[2]=bitmap target
6466 //
6467 // -2 is the current Render Target
6468 // -1, this is the screen (framebuf).
6469 // 0: Render target 0
6470 // 1: Render target 1
6471 // 2: Render target 2
6472 // 3: Render target 3
6473 // 4: Render target 4
6474 // 5: Render target 5
6475 // 6: Render target 6
6476 // Otherwise: The pointer to a bitmap.
6477
6478 //sdci[3]=sourcex
6479 //sdci[4]=sourcey
6480 //sdci[5]=sourcew
6481 //sdci[6]=sourceh
6482 //sdci[7]=destx
6483 //sdci[8]=desty
6484 //sdci[9]=destw
6485 //sdci[10]=desth
6486 //sdci[11]=rotation/angle
6487 //scdi[12] = pivot cx
6488 //sdci[13] = pivot cy
6489 //scdi[14] = effect flags
6490 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6491
6492 // ZScript-side constant values:
6493 const int32_t BITDX_NORMAL = 0;
6494 const int32_t BITDX_TRANS = 1; //Translucent
6495 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6496 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6497 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6498 //Note: Some modes cannot be combined. if a combination is not supported, an error
6499 // detailing this will be shown in allegro.log.
6500
6501 //scdi[15] = litcolour
6502 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6503 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6504
6505 //sdci[16]=mask
6506
6507 */
6508
6509 2062708 int32_t usr_bitmap_index = sdci[2];
6510 4125416 auto [bitmapIndex, is_user_bitmap] = resolveScriptingBitmapId(usr_bitmap_index);
6511
6512
6513 2062708 int32_t sx = sdci[3]/10000;
6514 2062708 int32_t sy = sdci[4]/10000;
6515 2062708 int32_t sw = sdci[5]/10000;
6516 2062708 int32_t sh = sdci[6]/10000;
6517 2062708 int32_t dx = sdci[7]/10000;
6518 2062708 int32_t dy = sdci[8]/10000;
6519 2062708 int32_t dw = sdci[9]/10000;
6520 2062708 int32_t dh = sdci[10]/10000;
6521 2062708 float rot = sdci[11]/10000;
6522 2062708 int32_t cx = sdci[12]/10000;
6523 2062708 int32_t cy = sdci[13]/10000;
6524 2062708 int32_t mode = sdci[14]/10000;
6525 2062708 int32_t litcolour = sdci[15]/10000;
6526 2062708 bool masked = (sdci[16] != 0);
6527
6528 2062708 int32_t ref = 0;
6529
6530
2/2
✓ Branch 0 taken 267486 times.
✓ Branch 1 taken 1795222 times.
2062708 if (get_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN))
6531 {
6532
2/2
✓ Branch 0 taken 95143 times.
✓ Branch 1 taken 172343 times.
267486 if (is_user_bitmap)
6533 172343 yoffset = 0;
6534
6535 267486 dx += xoffset;
6536 267486 dy += yoffset;
6537 267486 }
6538 else
6539 {
6540 1795222 dx += secondary_draw_origin_xoff;
6541 1795222 dy += secondary_draw_origin_yoff;
6542
6543 1795222 sx += xoffset;
6544 1795222 sy += yoffset;
6545 }
6546
6547 2062708 ref = sdci[DRAWCMD_BMP_TARGET];
6548
6549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2062708 times.
2062708 if ( ref <= 0 )
6550 {
6551 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6552 return;
6553 }
6554 2062708 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
6555
6556
1/2
✓ Branch 0 taken 2062708 times.
✗ Branch 1 not taken.
2062708 if(!sourceBitmap)
6557 {
6558
6559 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
6560 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6561 return;
6562 }
6563
6564 2062708 BITMAP *destBMP=NULL;
6565
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224018 times.
✓ Branch 2 taken 14218 times.
✓ Branch 3 taken 1824472 times.
2062708 switch(bitmapIndex)
6566 {
6567 // Current render target (RT_CURRENT).
6568 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
6569 case -2:
6570 {
6571 14218 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6572
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14218 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14218 if ( curr_rt >= 0 && curr_rt < 7 )
6573 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6574 14218 else destBMP = bmp; //screen
6575 14218 break;
6576 }
6577 case -1:
6578 1824472 destBMP = bmp; //this is framebuf, by default
6579 1824472 break;
6580 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
6581 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6582 //destBMP = framebuf; //Drawing to the screen.
6583 //break;
6584
6585 //1 through 6 are the old system bitmaps (Render Targets)
6586 case 0:
6587 case 1:
6588 case 2:
6589 case 3:
6590 case 4:
6591 case 5:
6592 case 6:
6593 {
6594 //This gets a render target.
6595 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
6596
6597 //destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6598 //sdci[18] = bitmapIndex;
6599 break;
6600 }
6601 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6602 default:
6603 {
6604 224018 auto& usr_bitmap = scb.get(usr_bitmap_index);
6605 224018 destBMP = usr_bitmap.u_bmp;
6606 //sdci[18] = usr_bitmap_index;
6607
1/2
✓ Branch 0 taken 224018 times.
✗ Branch 1 not taken.
224018 if ( !usr_bitmap.u_bmp )
6608 {
6609 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
6610 break;
6611 }
6612 }
6613 224018 }
6614
6615
1/2
✓ Branch 0 taken 2062708 times.
✗ Branch 1 not taken.
2062708 if (!destBMP)
6616 {
6617 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6618 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6619 return;
6620 }
6621
6622
2/2
✓ Branch 0 taken 1511 times.
✓ Branch 1 taken 2061197 times.
2062708 bool stretched = (sw != dw || sh != dh);
6623 2062708 BITMAP* subBmp = 0;
6624
6625
4/4
✓ Branch 0 taken 2061129 times.
✓ Branch 1 taken 1579 times.
✓ Branch 2 taken 25732 times.
✓ Branch 3 taken 2035397 times.
2062708 if(rot != 0 || mode != 0)
6626 {
6627 27311 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
6628 27311 clear_bitmap(subBmp);
6629
6630
1/2
✓ Branch 0 taken 27311 times.
✗ Branch 1 not taken.
27311 if(!subBmp)
6631 {
6632
6633 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
6634 return;
6635 }
6636 27311 }
6637 2062708 BITMAP* sbmp = sourceBitmap;
6638
3/4
✓ Branch 0 taken 2061946 times.
✓ Branch 1 taken 762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2061946 times.
2062708 if (sx + sw > sbmp->w || sy + sh > sbmp->h)
6639 {
6640 762 sbmp = create_bitmap_ex(8, sw, sh);
6641 762 clear_bitmap(sbmp);
6642 762 blit(sourceBitmap, sbmp, sx, sy, 0, 0, std::min(sourceBitmap->w-sx, sw), std::min(sourceBitmap->h-sy, sh));
6643 762 sx = 0;
6644 762 sy = 0;
6645 762 }
6646 //dx = dx + xoffset; //don't do this here!
6647 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6648
6649
2/2
✓ Branch 0 taken 2086 times.
✓ Branch 1 taken 2060622 times.
2062708 if(stretched)
6650 {
6651
2/2
✓ Branch 0 taken 1475 times.
✓ Branch 1 taken 611 times.
2086 if(masked)
6652 { //stretched and masked
6653
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 901 times.
1475 if ( rot == 0 )
6654 { //if not rotated
6655
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
901 switch(mode)
6656 {
6657 case 1:
6658 //transparent
6659 900 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6660 900 draw_trans_sprite(destBMP, subBmp, dx, dy);
6661 900 break;
6662
6663
6664 case 2:
6665 //pivot?
6666 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6667 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6668 //Pivoting requires two more args
6669 break;
6670
6671 case 3:
6672 //pivot + trans
6673 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6674 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6675 break;
6676
6677 case 4:
6678 //flip v
6679 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6680 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6681 break;
6682
6683 case 5:
6684 //trans + v flip
6685 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6686 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6687 break;
6688
6689 case 6:
6690 //pivot + v flip
6691 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6692 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6693 break;
6694
6695 case 8:
6696 //vlip h
6697 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6698 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6699 break;
6700
6701 case 9:
6702 //trans + h flip
6703 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6704 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6705 break;
6706
6707 case 10:
6708 //flip H and pivot
6709 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6710 //return error cannot pivot and h flip
6711 break;
6712
6713 case 12:
6714 //vh flip
6715 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6716 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
6717 break;
6718
6719 case 13:
6720 //trans + vh flip
6721 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6722 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
6723 break;
6724
6725 case 14:
6726 //pivot and vh flip
6727 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6728 //return error cannot both pivot and vh flip
6729 break;
6730
6731 case 16:
6732 //lit
6733 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6734 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
6735 break;
6736
6737 case 18:
6738 //pivot, lit
6739 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6740 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6741 break;
6742
6743 case 20:
6744 //lit + v flip
6745 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6746 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
6747 break;
6748
6749 case 22:
6750 //Pivot, vflip, lit
6751 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6752 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6753 break;
6754
6755 case 24:
6756 //lit + h flip
6757 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6758 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
6759 break;
6760
6761 case 26:
6762 //pivot + lit + hflip
6763 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
6764 //return error cannot pivot, lit, and flip
6765 break;
6766
6767 case 28:
6768 //lit + vh flip
6769 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6770 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
6771 break;
6772
6773 case 32: //gouraud
6774 //Probably not wort supporting.
6775 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6776 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6777 break;
6778
6779 case 0:
6780 //no effect
6781 1 masked_stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
6782 1 break;
6783
6784
6785 default:
6786
6787 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6788
6789
6790 }
6791 901 } //end if not rotated
6792
6793
2/2
✓ Branch 0 taken 901 times.
✓ Branch 1 taken 574 times.
1475 if ( rot != 0 ) //if rotated
6794 {
6795
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 574 times.
✗ Branch 21 not taken.
574 switch(mode)
6796 {
6797 case 1:
6798 //transparent
6799 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6800 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6801
6802 break;
6803
6804 case 2:
6805 //pivot?
6806 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6807 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6808 //Pivoting requires two more args
6809 break;
6810
6811 case 3:
6812 //pivot + trans
6813 //return an error, cannot both rotate and pivot
6814 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6815 break;
6816
6817 case 4:
6818 //flip v
6819 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6820 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6821 break;
6822
6823 case 5:
6824 //trans + v flip
6825 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6826 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6827 break;
6828
6829 case 6:
6830 //pivot + v flip
6831 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6832 //return an error, cannot both rotate and pivot
6833 break;
6834
6835 case 8:
6836 //flip h
6837 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
6838 //return an error, cannot both rotate and flip H
6839 break;
6840
6841 case 9:
6842 //trans + h flip
6843 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
6844 //return an error, cannot rotate and flip a trans sprite
6845 break;
6846
6847 case 10:
6848 //flip H and pivot
6849 //return error cannot pivot and h flip
6850 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6851 break;
6852
6853 case 12:
6854 //vh flip
6855 //return an error, cannot rotate and VH flip a trans sprite
6856 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6857 break;
6858
6859 case 13:
6860 //trans + vh flip
6861 //return an error, cannot rotate and VH flip a trans sprite
6862 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6863 break;
6864
6865 case 14:
6866 //pivot and vh flip
6867 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6868 //return error cannot both pivot and vh flip
6869 break;
6870
6871 case 16:
6872 //lit
6873 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6874 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6875 break;
6876
6877 case 18:
6878 //pivot, lit
6879 //return an error, cannot both rotate and pivot
6880 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6881 break;
6882
6883 case 20:
6884 //lit + vflip
6885 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6886 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6887 break;
6888
6889 case 22:
6890 //Pivot, vflip, lit
6891 //return an error, cannot both rotate and pivot
6892 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6893 break;
6894
6895 case 24:
6896 //lit + h flip
6897 //return an error, cannot both rotate and H flip
6898 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
6899 break;
6900
6901 case 26:
6902 //pivot + lit + hflip
6903 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
6904 //return error cannot pivot, lit, and flip
6905 break;
6906
6907 case 28:
6908 //lit + vh flip
6909 //return an error, cannot both rotate and VH flip
6910 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6911 break;
6912
6913 case 32: //gouraud
6914 //Probably not wort supporting.
6915 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6916 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6917 break;
6918
6919 case 0:
6920 //no effect.
6921 574 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6922 574 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6923 574 break;
6924
6925 default:
6926
6927 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6928
6929 }
6930 574 }
6931 1475 } //end if stretched and masked
6932
6933 else //stretched, not masked
6934 {
6935
6936
6937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
611 if ( rot == 0 ) //if not rotated
6938 {
6939
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 611 times.
611 switch(mode)
6940 {
6941 case 1:
6942 //transparent
6943 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6944 draw_trans_sprite(destBMP, subBmp, dx, dy);
6945 break;
6946
6947
6948 case 2:
6949 //pivot?
6950 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6951 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6952 //Pivoting requires two more args
6953 break;
6954
6955 case 3:
6956 //pivot + trans
6957 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6958 pivot_sprite_trans(destBMP, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
6959 break;
6960
6961 case 4:
6962 //flip v
6963 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6964 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6965 break;
6966
6967 case 5:
6968 //trans + v flip
6969 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6970 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6971 break;
6972
6973 case 6:
6974 //pivot + v flip
6975 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6976 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6977 break;
6978
6979 case 8:
6980 //vlip h
6981 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6982 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6983 break;
6984
6985 case 9:
6986 //trans + h flip
6987 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6988 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6989 break;
6990
6991 case 10:
6992 //flip H and pivot
6993 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6994 //return error cannot pivot and h flip
6995 break;
6996
6997 case 12:
6998 //vh flip
6999 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7000 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7001 break;
7002
7003 case 13:
7004 //trans + vh flip
7005 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7006 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7007 break;
7008
7009 case 14:
7010 //pivot and vh flip
7011 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7012 //return error cannot both pivot and vh flip
7013 break;
7014
7015 case 16:
7016 //lit
7017 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7018 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7019 break;
7020
7021 case 18:
7022 //pivot, lit
7023 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7024 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7025 break;
7026
7027 case 20:
7028 //lit + v flip
7029 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7030 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7031 break;
7032
7033 case 22:
7034 //Pivot, vflip, lit
7035 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7036 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7037 break;
7038
7039 case 24:
7040 //lit + h flip
7041 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7042 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7043 break;
7044
7045 case 26:
7046 //pivot + lit + hflip
7047 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7048 //return error cannot pivot, lit, and flip
7049 break;
7050
7051 case 28:
7052 //lit + vh flip
7053 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7054 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7055 break;
7056
7057 case 32: //gouraud
7058 //Probably not wort supporting.
7059 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7060 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7061 break;
7062
7063 case 0:
7064 //no effect
7065 611 stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
7066 611 break;
7067
7068
7069 default:
7070
7071 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7072
7073
7074 }
7075 611 } //end if not rotated
7076
7077
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if ( rot != 0 ) //if rotated
7078 {
7079 switch(mode)
7080 {
7081 case 1:
7082 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7083 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7084
7085 break;
7086
7087 case 2:
7088 //pivot?
7089 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7090 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7091 //Pivoting requires two more args
7092 break;
7093
7094 case 3:
7095 //pivot + trans
7096 //return an error, cannot both rotate and pivot
7097 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7098 break;
7099
7100 case 4:
7101 //flip v
7102 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7103 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7104 break;
7105
7106 case 5:
7107 //trans + v flip
7108 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7109 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7110 break;
7111
7112 case 6:
7113 //pivot + v flip
7114 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7115 //return an error, cannot both rotate and pivot
7116 break;
7117
7118 case 8:
7119 //flip h
7120 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7121 //return an error, cannot both rotate and flip H
7122 break;
7123
7124 case 9:
7125 //trans + h flip
7126 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7127 //return an error, cannot rotate and flip a trans sprite
7128 break;
7129
7130 case 10:
7131 //flip H and pivot
7132 //return error cannot pivot and h flip
7133 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7134 break;
7135
7136 case 12:
7137 //vh flip
7138 //return an error, cannot rotate and VH flip a trans sprite
7139 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7140 break;
7141
7142 case 13:
7143 //trans + vh flip
7144 //return an error, cannot rotate and VH flip a trans sprite
7145 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7146 break;
7147
7148 case 14:
7149 //pivot and vh flip
7150 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7151 //return error cannot both pivot and vh flip
7152 break;
7153
7154 case 16:
7155 //lit
7156 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7157 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7158 break;
7159
7160 case 18:
7161 //pivot, lit
7162 //return an error, cannot both rotate and pivot
7163 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7164 break;
7165
7166 case 20:
7167 //lit + vflip
7168 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7169 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7170 break;
7171
7172 case 22:
7173 //Pivot, vflip, lit
7174 //return an error, cannot both rotate and pivot
7175 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7176 break;
7177
7178 case 24:
7179 //lit + h flip
7180 //return an error, cannot both rotate and H flip
7181 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7182 break;
7183
7184 case 26:
7185 //pivot + lit + hflip
7186 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7187 //return error cannot pivot, lit, and flip
7188 break;
7189
7190 case 28:
7191 //lit + vh flip
7192 //return an error, cannot both rotate and VH flip
7193 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7194 break;
7195
7196 case 32: //gouraud
7197 //Probably not wort supporting.
7198 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7199 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7200 break;
7201
7202 case 0:
7203 //no effect.
7204 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7205 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7206 break;
7207
7208 default:
7209
7210 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7211
7212 }
7213 }
7214
7215 } //end if stretched, but not masked
7216 2086 }
7217 else //not stretched
7218 {
7219
7220
2/2
✓ Branch 0 taken 1982848 times.
✓ Branch 1 taken 77774 times.
2060622 if(masked) //if masked, but not stretched
7221 {
7222
7223
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 1981843 times.
1982848 if ( rot == 0 ) //if not rotated
7224 {
7225
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 19118 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1962725 times.
1981843 switch(mode)
7226 {
7227 case 1:
7228 //transparent
7229 19118 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7230 19118 draw_trans_sprite(destBMP, subBmp, dx, dy);
7231 19118 break;
7232
7233
7234 case 2:
7235 //pivot?
7236 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7237 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7238 //Pivoting requires two more args
7239 break;
7240
7241 case 3:
7242 //pivot + trans
7243 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7244 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7245 break;
7246
7247 case 4:
7248 //flip v
7249 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7250 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7251 break;
7252
7253 case 5:
7254 //trans + v flip
7255 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7256 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7257 break;
7258
7259 case 6:
7260 //pivot + v flip
7261 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7262 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7263 break;
7264
7265 case 8:
7266 //vlip h
7267 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7268 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7269 break;
7270
7271 case 9:
7272 //trans + h flip
7273 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7274 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7275 break;
7276
7277 case 10:
7278 //flip H and pivot
7279 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7280 //return error cannot pivot and h flip
7281 break;
7282
7283 case 12:
7284 //vh flip
7285 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7286 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7287 break;
7288
7289 case 13:
7290 //trans + vh flip
7291 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7292 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7293 break;
7294
7295 case 14:
7296 //pivot and vh flip
7297 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7298 //return error cannot both pivot and vh flip
7299 break;
7300
7301 case 16:
7302 //lit
7303 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7304 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7305 break;
7306
7307 case 18:
7308 //pivot, lit
7309 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7310 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7311 break;
7312
7313 case 20:
7314 //lit + v flip
7315 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7316 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7317 break;
7318
7319 case 22:
7320 //Pivot, vflip, lit
7321 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7322 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7323 break;
7324
7325 case 24:
7326 //lit + h flip
7327 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7328 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7329 break;
7330
7331 case 26:
7332 //pivot + lit + hflip
7333 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7334 //return error cannot pivot, lit, and flip
7335 break;
7336
7337 case 28:
7338 //lit + vh flip
7339 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7340 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7341 break;
7342
7343 case 32: //gouraud
7344 //Probably not wort supporting.
7345 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7346 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7347 break;
7348
7349 case 0:
7350 //no effect
7351 1962725 masked_blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7352 1962725 break;
7353
7354
7355 default:
7356
7357 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7358
7359
7360 }
7361 1981843 } //end if not rotated
7362
7363
2/2
✓ Branch 0 taken 1981843 times.
✓ Branch 1 taken 1005 times.
1982848 if ( rot != 0 ) //if rotated
7364 {
7365
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1005 times.
✗ Branch 21 not taken.
1005 switch(mode)
7366 {
7367 case 1:
7368 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
7369 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7370
7371 break;
7372
7373 case 2:
7374 //pivot?
7375 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7376 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7377 //Pivoting requires two more args
7378 break;
7379
7380 case 3:
7381 //pivot + trans
7382 //return an error, cannot both rotate and pivot
7383 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7384 break;
7385
7386 case 4:
7387 //flip v
7388 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7389 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7390 break;
7391
7392 case 5:
7393 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
7394 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7395 break;
7396
7397 case 6:
7398 //pivot + v flip
7399 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7400 //return an error, cannot both rotate and pivot
7401 break;
7402
7403 case 8:
7404 //flip h
7405 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7406 //return an error, cannot both rotate and flip H
7407 break;
7408
7409 case 9:
7410 //trans + h flip
7411 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7412 //return an error, cannot rotate and flip a trans sprite
7413 break;
7414
7415 case 10:
7416 //flip H and pivot
7417 //return error cannot pivot and h flip
7418 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7419 break;
7420
7421 case 12:
7422 //vh flip
7423 //return an error, cannot rotate and VH flip a trans sprite
7424 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7425 break;
7426
7427 case 13:
7428 //trans + vh flip
7429 //return an error, cannot rotate and VH flip a trans sprite
7430 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7431 break;
7432
7433 case 14:
7434 //pivot and vh flip
7435 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7436 //return error cannot both pivot and vh flip
7437 break;
7438
7439 case 16:
7440 //lit
7441 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7442 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7443 break;
7444
7445 case 18:
7446 //pivot, lit
7447 //return an error, cannot both rotate and pivot
7448 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7449 break;
7450
7451 case 20:
7452 //lit + vflip
7453 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7454 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7455 break;
7456
7457 case 22:
7458 //Pivot, vflip, lit
7459 //return an error, cannot both rotate and pivot
7460 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7461 break;
7462
7463 case 24:
7464 //lit + h flip
7465 //return an error, cannot both rotate and H flip
7466 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7467 break;
7468
7469 case 26:
7470 //pivot + lit + hflip
7471 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7472 //return error cannot pivot, lit, and flip
7473 break;
7474
7475 case 28:
7476 //lit + vh flip
7477 //return an error, cannot both rotate and VH flip
7478 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7479 break;
7480
7481 case 32: //gouraud
7482 //Probably not wort supporting.
7483 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7484 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7485 break;
7486
7487 case 0:
7488 //no effect.
7489 1005 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7490 1005 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7491 1005 break;
7492
7493 default:
7494
7495 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7496
7497 }
7498 1005 } //end rtated, masked
7499 1982848 } //end if masked
7500
7501 else //not masked, and not stretched; just blit
7502 {
7503
7504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77774 times.
77774 if ( rot == 0 ) //if not rotated
7505 {
7506
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 5714 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 72060 times.
77774 switch(mode)
7507 {
7508 case 1:
7509 //transparent
7510 5714 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7511 5714 draw_trans_sprite(destBMP, subBmp, dx, dy);
7512 5714 break;
7513
7514
7515 case 2:
7516 //pivot?
7517 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7518 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7519 //Pivoting requires two more args
7520 break;
7521
7522 case 3:
7523 //pivot + trans
7524 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7525 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7526 break;
7527
7528 case 4:
7529 //flip v
7530 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7531 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7532 break;
7533
7534 case 5:
7535 //trans + v flip
7536 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7537 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7538 break;
7539
7540 case 6:
7541 //pivot + v flip
7542 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7543 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7544 break;
7545
7546 case 8:
7547 //vlip h
7548 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7549 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7550 break;
7551
7552 case 9:
7553 //trans + h flip
7554 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7555 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7556 break;
7557
7558 case 10:
7559 //flip H and pivot
7560 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7561 //return error cannot pivot and h flip
7562 break;
7563
7564 case 12:
7565 //vh flip
7566 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7567 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7568 break;
7569
7570 case 13:
7571 //trans + vh flip
7572 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7573 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7574 break;
7575
7576 case 14:
7577 //pivot and vh flip
7578 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7579 //return error cannot both pivot and vh flip
7580 break;
7581
7582 case 16:
7583 //lit
7584 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7585 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7586 break;
7587
7588 case 18:
7589 //pivot, lit
7590 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7591 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7592 break;
7593
7594 case 20:
7595 //lit + v flip
7596 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7597 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7598 break;
7599
7600 case 22:
7601 //Pivot, vflip, lit
7602 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7603 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7604 break;
7605
7606 case 24:
7607 //lit + h flip
7608 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7609 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7610 break;
7611
7612 case 26:
7613 //pivot + lit + hflip
7614 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7615 //return error cannot pivot, lit, and flip
7616 break;
7617
7618 case 28:
7619 //lit + vh flip
7620 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7621 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7622 break;
7623
7624 case 32: //gouraud
7625 //Probably not wort supporting.
7626 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7627 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7628 break;
7629
7630 case 0:
7631 //no effect
7632 72060 blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7633 72060 break;
7634
7635
7636 default:
7637
7638 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7639
7640
7641 }
7642 77774 } //end if not rotated
7643
7644
1/2
✓ Branch 0 taken 77774 times.
✗ Branch 1 not taken.
77774 if ( rot != 0 ) //if rotated
7645 {
7646 switch(mode)
7647 {
7648 case 1:
7649 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
7650 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7651
7652 break;
7653
7654 case 2:
7655 //pivot?
7656 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7657 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7658 //Pivoting requires two more args
7659 break;
7660
7661 case 3:
7662 //pivot + trans
7663 //return an error, cannot both rotate and pivot
7664 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7665 break;
7666
7667 case 4:
7668 //flip v
7669 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7670 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7671 break;
7672
7673 case 5:
7674 //trans + v flip
7675 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7676 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7677 break;
7678
7679 case 6:
7680 //pivot + v flip
7681 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7682 //return an error, cannot both rotate and pivot
7683 break;
7684
7685 case 8:
7686 //flip h
7687 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7688 //return an error, cannot both rotate and flip H
7689 break;
7690
7691 case 9:
7692 //trans + h flip
7693 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7694 //return an error, cannot rotate and flip a trans sprite
7695 break;
7696
7697 case 10:
7698 //flip H and pivot
7699 //return error cannot pivot and h flip
7700 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7701 break;
7702
7703 case 12:
7704 //vh flip
7705 //return an error, cannot rotate and VH flip a trans sprite
7706 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7707 break;
7708
7709 case 13:
7710 //trans + vh flip
7711 //return an error, cannot rotate and VH flip a trans sprite
7712 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7713 break;
7714
7715 case 14:
7716 //pivot and vh flip
7717 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7718 //return error cannot both pivot and vh flip
7719 break;
7720
7721 case 16:
7722 //lit
7723 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7724 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7725 break;
7726
7727 case 18:
7728 //pivot, lit
7729 //return an error, cannot both rotate and pivot
7730 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7731 break;
7732
7733 case 20:
7734 //lit + vflip
7735 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7736 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7737 break;
7738
7739 case 22:
7740 //Pivot, vflip, lit
7741 //return an error, cannot both rotate and pivot
7742 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7743 break;
7744
7745 case 24:
7746 //lit + h flip
7747 //return an error, cannot both rotate and H flip
7748 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7749 break;
7750
7751 case 26:
7752 //pivot + lit + hflip
7753 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7754 //return error cannot pivot, lit, and flip
7755 break;
7756
7757 case 28:
7758 //lit + vh flip
7759 //return an error, cannot both rotate and VH flip
7760 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7761 break;
7762
7763 case 32: //gouraud
7764 //Probably not wort supporting.
7765 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7766 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7767 break;
7768
7769 case 0:
7770 //no effect.
7771 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7772 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7773 break;
7774
7775 default:
7776
7777 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7778
7779 }
7780 } //end if rotated
7781 } //end if not masked
7782 } //end if not stretched
7783
7784 //cleanup
7785
2/2
✓ Branch 0 taken 27311 times.
✓ Branch 1 taken 2035397 times.
2062708 if(subBmp)
7786 {
7787 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
7788 27311 destroy_bitmap(subBmp);
7789 27311 }
7790
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 2061946 times.
2062708 if (sbmp != sourceBitmap)
7791 {
7792 762 destroy_bitmap(sbmp);
7793 762 }
7794 2062708 }
7795
7796
7797
7798 113653 void bmp_do_blittor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
7799 {
7800 /*
7801 //sdci[1]=layer
7802 //sdci[2]=bitmap target
7803 //
7804 // -2 is the current Render Target
7805 // -1, this is the screen (framebuf).
7806 // 0: Render target 0
7807 // 1: Render target 1
7808 // 2: Render target 2
7809 // 3: Render target 3
7810 // 4: Render target 4
7811 // 5: Render target 5
7812 // 6: Render target 6
7813 // Otherwise: The pointer to a bitmap.
7814
7815 //sdci[3]=sourcex
7816 //sdci[4]=sourcey
7817 //sdci[5]=sourcew
7818 //sdci[6]=sourceh
7819 //sdci[7]=destx
7820 //sdci[8]=desty
7821 //sdci[9]=destw
7822 //sdci[10]=desth
7823 //sdci[11]=rotation/angle
7824 //scdi[12] = pivot cx
7825 //sdci[13] = pivot cy
7826 //scdi[14] = effect flags
7827 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
7828
7829 // ZScript-side constant values:
7830 const int32_t BITDX_NORMAL = 0;
7831 const int32_t BITDX_TRANS = 1; //Translucent
7832 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
7833 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
7834 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
7835 //Note: Some modes cannot be combined. if a combination is not supported, an error
7836 // detailing this will be shown in allegro.log.
7837
7838 //scdi[15] = litcolour
7839 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7840 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
7841
7842 //sdci[16]=mask
7843
7844 */
7845
7846 113653 int32_t srcyoffset = yoffset, srcxoffset = xoffset;
7847
7848 113653 int32_t usr_bitmap_index = sdci[2];
7849 340955 auto [bitmapIndex, is_user_bitmap] = resolveScriptingBitmapId(usr_bitmap_index);
7850
7851 113653 int32_t sx = sdci[3]/10000;
7852 113653 int32_t sy = sdci[4]/10000;
7853 113653 int32_t sw = sdci[5]/10000;
7854 113653 int32_t sh = sdci[6]/10000;
7855 113653 int32_t dx = sdci[7]/10000;
7856 113653 int32_t dy = sdci[8]/10000;
7857 113653 int32_t dw = sdci[9]/10000;
7858 113653 int32_t dh = sdci[10]/10000;
7859 113653 float rot = sdci[11]/10000;
7860 113653 int32_t cx = sdci[12]/10000;
7861 113653 int32_t cy = sdci[13]/10000;
7862 113653 int32_t mode = sdci[14]/10000;
7863 113653 int32_t litcolour = sdci[15]/10000;
7864 113653 bool masked = (sdci[16] != 0);
7865
7866 113653 int32_t ref = 0;
7867
7868
2/2
✓ Branch 0 taken 113649 times.
✓ Branch 1 taken 4 times.
113653 if (get_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN))
7869 {
7870
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 113386 times.
113649 if (is_user_bitmap)
7871 113386 srcyoffset = 0;
7872
2/4
✓ Branch 0 taken 113649 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113649 times.
113649 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
7873
3/4
✓ Branch 0 taken 113649 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 113646 times.
113649 if ( (bitmapIndex) != -2 && (bitmapIndex) != -1 ) srcyoffset = 0; //Don't crop.
7874
7875 113649 dx += xoffset;
7876 113649 dy += yoffset;
7877
7878 113649 sx += srcxoffset;
7879 113649 sy += srcyoffset;
7880 113649 }
7881 else
7882 {
7883 4 dx += xoffset;
7884 4 dy += yoffset;
7885
7886 4 sx += secondary_draw_origin_xoff;
7887 4 sy += secondary_draw_origin_yoff;
7888 }
7889
7890 113653 ref = sdci[DRAWCMD_BMP_TARGET];
7891
7892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113653 times.
113653 if ( ref <= 0 )
7893 {
7894 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
7895 return;
7896 }
7897 113653 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
7898
1/2
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
113653 if(!sourceBitmap)
7899 {
7900 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
7901 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
7902 return;
7903 }
7904
7905 113653 BITMAP *destBMP=NULL;
7906
7907
3/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 113386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
113653 switch(bitmapIndex)
7908 {
7909 // Current render target (RT_CURRENT).
7910 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
7911 case -2:
7912 {
7913 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
7914 if ( curr_rt >= 0 && curr_rt < 7 )
7915 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
7916 else destBMP = bmp; //screen
7917 break;
7918 }
7919 case -1:
7920 7 destBMP = bmp; //this is framebuf, by default
7921 7 break;
7922 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
7923 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
7924 //destBMP = framebuf; //Drawing to the screen.
7925 //break;
7926
7927 //1 through 6 are the old system bitmaps (Render Targets)
7928 case 0:
7929 case 1:
7930 case 2:
7931 case 3:
7932 case 4:
7933 case 5:
7934 case 6:
7935 {
7936 //This gets a render target.
7937 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
7938
7939 520 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
7940 //sdci[18] = bitmapIndex;
7941 260 break;
7942 }
7943 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
7944 default:
7945 {
7946 113386 auto& usr_bitmap = scb.get(usr_bitmap_index);
7947 113386 destBMP = usr_bitmap.u_bmp;
7948 //sdci[18] = usr_bitmap_index;
7949
1/2
✓ Branch 0 taken 113386 times.
✗ Branch 1 not taken.
113386 if ( !usr_bitmap.u_bmp )
7950 {
7951 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
7952 break;
7953 }
7954 }
7955 113386 }
7956
7957
1/2
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
113653 if (!destBMP)
7958 {
7959 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
7960 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
7961 return;
7962 }
7963
7964
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 113343 times.
113653 bool stretched = (sw != dw || sh != dh);
7965
7966 113653 BITMAP* newDest = sourceBitmap;
7967 113653 BITMAP* newSource = destBMP; //Flip them.
7968
7969 113653 BITMAP* subBmp = 0;
7970
7971
2/4
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113653 times.
113653 if(rot != 0 || mode != 0)
7972 {
7973 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
7974 clear_bitmap(subBmp);
7975
7976 if(!subBmp)
7977 {
7978 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
7979 return;
7980 }
7981 }
7982
7983
3/4
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 113650 times.
113653 if (sx + sw > destBMP->w || sy + sh > destBMP->h)
7984 {
7985 3 newSource = create_bitmap_ex(8, sw, sh);
7986 3 clear_bitmap(newSource);
7987 3 blit(destBMP, newSource, sx, sy, 0, 0, std::min(destBMP->w-sx, sw), std::min(destBMP->h-sy, sh));
7988 3 sx = 0;
7989 3 sy = 0;
7990 3 }
7991 //dx = dx + xoffset; //don't do this here!
7992 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
7993
7994
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 113343 times.
113653 if(stretched)
7995 {
7996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(masked)
7997 { //stretched and masked
7998 if ( rot == 0 )
7999 { //if not rotated
8000 switch(mode)
8001 {
8002 case 1:
8003 //transparent
8004 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8005 draw_trans_sprite(newDest, subBmp, dx, dy);
8006 break;
8007
8008
8009 case 2:
8010 //pivot?
8011 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8012 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8013 //Pivoting requires two more args
8014 break;
8015
8016 case 3:
8017 //pivot + trans
8018 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8019 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8020 break;
8021
8022 case 4:
8023 //flip v
8024 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8025 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8026 break;
8027
8028 case 5:
8029 //trans + v flip
8030 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8031 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8032 break;
8033
8034 case 6:
8035 //pivot + v flip
8036 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8037 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8038 break;
8039
8040 case 8:
8041 //vlip h
8042 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8043 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8044 break;
8045
8046 case 9:
8047 //trans + h flip
8048 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8049 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8050 break;
8051
8052 case 10:
8053 //flip H and pivot
8054 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8055 //return error cannot pivot and h flip
8056 break;
8057
8058 case 12:
8059 //vh flip
8060 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8061 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8062 break;
8063
8064 case 13:
8065 //trans + vh flip
8066 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8067 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8068 break;
8069
8070 case 14:
8071 //pivot and vh flip
8072 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8073 //return error cannot both pivot and vh flip
8074 break;
8075
8076 case 16:
8077 //lit
8078 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8079 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8080 break;
8081
8082 case 18:
8083 //pivot, lit
8084 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8085 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8086 break;
8087
8088 case 20:
8089 //lit + v flip
8090 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8091 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8092 break;
8093
8094 case 22:
8095 //Pivot, vflip, lit
8096 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8097 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8098 break;
8099
8100 case 24:
8101 //lit + h flip
8102 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8103 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8104 break;
8105
8106 case 26:
8107 //pivot + lit + hflip
8108 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8109 //return error cannot pivot, lit, and flip
8110 break;
8111
8112 case 28:
8113 //lit + vh flip
8114 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8115 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8116 break;
8117
8118 case 32: //gouraud
8119 //Probably not wort supporting.
8120 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8121 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8122 break;
8123
8124 case 0:
8125 //no effect
8126 masked_stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8127 break;
8128
8129
8130 default:
8131 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8132
8133
8134 }
8135 } //end if not rotated
8136
8137 if ( rot != 0 ) //if rotated
8138 {
8139 switch(mode)
8140 {
8141 case 1:
8142 //transparent
8143 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8144 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8145
8146 break;
8147
8148 case 2:
8149 //pivot?
8150 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8151 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8152 //Pivoting requires two more args
8153 break;
8154
8155 case 3:
8156 //pivot + trans
8157 //return an error, cannot both rotate and pivot
8158 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8159 break;
8160
8161 case 4:
8162 //flip v
8163 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8164 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8165 break;
8166
8167 case 5:
8168 //trans + v flip
8169 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8170 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8171 break;
8172
8173 case 6:
8174 //pivot + v flip
8175 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8176 //return an error, cannot both rotate and pivot
8177 break;
8178
8179 case 8:
8180 //flip h
8181 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8182 //return an error, cannot both rotate and flip H
8183 break;
8184
8185 case 9:
8186 //trans + h flip
8187 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8188 //return an error, cannot rotate and flip a trans sprite
8189 break;
8190
8191 case 10:
8192 //flip H and pivot
8193 //return error cannot pivot and h flip
8194 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8195 break;
8196
8197 case 12:
8198 //vh flip
8199 //return an error, cannot rotate and VH flip a trans sprite
8200 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8201 break;
8202
8203 case 13:
8204 //trans + vh flip
8205 //return an error, cannot rotate and VH flip a trans sprite
8206 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8207 break;
8208
8209 case 14:
8210 //pivot and vh flip
8211 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8212 //return error cannot both pivot and vh flip
8213 break;
8214
8215 case 16:
8216 //lit
8217 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8218 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8219 break;
8220
8221 case 18:
8222 //pivot, lit
8223 //return an error, cannot both rotate and pivot
8224 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8225 break;
8226
8227 case 20:
8228 //lit + vflip
8229 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8230 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8231 break;
8232
8233 case 22:
8234 //Pivot, vflip, lit
8235 //return an error, cannot both rotate and pivot
8236 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8237 break;
8238
8239 case 24:
8240 //lit + h flip
8241 //return an error, cannot both rotate and H flip
8242 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8243 break;
8244
8245 case 26:
8246 //pivot + lit + hflip
8247 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8248 //return error cannot pivot, lit, and flip
8249 break;
8250
8251 case 28:
8252 //lit + vh flip
8253 //return an error, cannot both rotate and VH flip
8254 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8255 break;
8256
8257 case 32: //gouraud
8258 //Probably not wort supporting.
8259 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8260 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8261 break;
8262
8263 case 0:
8264 //no effect.
8265 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8266 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8267 break;
8268
8269 default:
8270 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8271
8272 }
8273 }
8274 } //end if stretched and masked
8275
8276 else //stretched, not masked
8277 {
8278
8279
8280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if ( rot == 0 ) //if not rotated
8281 {
8282
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 310 times.
310 switch(mode)
8283 {
8284 case 1:
8285 //transparent
8286 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8287 draw_trans_sprite(newDest, subBmp, dx, dy);
8288 break;
8289
8290
8291 case 2:
8292 //pivot?
8293 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8294 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8295 //Pivoting requires two more args
8296 break;
8297
8298 case 3:
8299 //pivot + trans
8300 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8301 pivot_sprite_trans(newDest, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
8302 break;
8303
8304 case 4:
8305 //flip v
8306 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8307 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8308 break;
8309
8310 case 5:
8311 //trans + v flip
8312 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8313 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8314 break;
8315
8316 case 6:
8317 //pivot + v flip
8318 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8319 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8320 break;
8321
8322 case 8:
8323 //vlip h
8324 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8325 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8326 break;
8327
8328 case 9:
8329 //trans + h flip
8330 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8331 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8332 break;
8333
8334 case 10:
8335 //flip H and pivot
8336 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8337 //return error cannot pivot and h flip
8338 break;
8339
8340 case 12:
8341 //vh flip
8342 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8343 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8344 break;
8345
8346 case 13:
8347 //trans + vh flip
8348 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8349 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8350 break;
8351
8352 case 14:
8353 //pivot and vh flip
8354 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8355 //return error cannot both pivot and vh flip
8356 break;
8357
8358 case 16:
8359 //lit
8360 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8361 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8362 break;
8363
8364 case 18:
8365 //pivot, lit
8366 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8367 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8368 break;
8369
8370 case 20:
8371 //lit + v flip
8372 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8373 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8374 break;
8375
8376 case 22:
8377 //Pivot, vflip, lit
8378 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8379 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8380 break;
8381
8382 case 24:
8383 //lit + h flip
8384 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8385 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8386 break;
8387
8388 case 26:
8389 //pivot + lit + hflip
8390 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8391 //return error cannot pivot, lit, and flip
8392 break;
8393
8394 case 28:
8395 //lit + vh flip
8396 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8397 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8398 break;
8399
8400 case 32: //gouraud
8401 //Probably not wort supporting.
8402 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8403 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8404 break;
8405
8406 case 0:
8407 //no effect
8408 310 stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8409 310 break;
8410
8411
8412 default:
8413 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8414
8415
8416 }
8417 310 } //end if not rotated
8418
8419
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 if ( rot != 0 ) //if rotated
8420 {
8421 switch(mode)
8422 {
8423 case 1:
8424 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8425 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8426
8427 break;
8428
8429 case 2:
8430 //pivot?
8431 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8432 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8433 //Pivoting requires two more args
8434 break;
8435
8436 case 3:
8437 //pivot + trans
8438 //return an error, cannot both rotate and pivot
8439 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8440 break;
8441
8442 case 4:
8443 //flip v
8444 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8445 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8446 break;
8447
8448 case 5:
8449 //trans + v flip
8450 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8451 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8452 break;
8453
8454 case 6:
8455 //pivot + v flip
8456 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8457 //return an error, cannot both rotate and pivot
8458 break;
8459
8460 case 8:
8461 //flip h
8462 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8463 //return an error, cannot both rotate and flip H
8464 break;
8465
8466 case 9:
8467 //trans + h flip
8468 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8469 //return an error, cannot rotate and flip a trans sprite
8470 break;
8471
8472 case 10:
8473 //flip H and pivot
8474 //return error cannot pivot and h flip
8475 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8476 break;
8477
8478 case 12:
8479 //vh flip
8480 //return an error, cannot rotate and VH flip a trans sprite
8481 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8482 break;
8483
8484 case 13:
8485 //trans + vh flip
8486 //return an error, cannot rotate and VH flip a trans sprite
8487 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8488 break;
8489
8490 case 14:
8491 //pivot and vh flip
8492 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8493 //return error cannot both pivot and vh flip
8494 break;
8495
8496 case 16:
8497 //lit
8498 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8499 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8500 break;
8501
8502 case 18:
8503 //pivot, lit
8504 //return an error, cannot both rotate and pivot
8505 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8506 break;
8507
8508 case 20:
8509 //lit + vflip
8510 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8511 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8512 break;
8513
8514 case 22:
8515 //Pivot, vflip, lit
8516 //return an error, cannot both rotate and pivot
8517 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8518 break;
8519
8520 case 24:
8521 //lit + h flip
8522 //return an error, cannot both rotate and H flip
8523 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8524 break;
8525
8526 case 26:
8527 //pivot + lit + hflip
8528 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8529 //return error cannot pivot, lit, and flip
8530 break;
8531
8532 case 28:
8533 //lit + vh flip
8534 //return an error, cannot both rotate and VH flip
8535 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8536 break;
8537
8538 case 32: //gouraud
8539 //Probably not wort supporting.
8540 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8541 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8542 break;
8543
8544 case 0:
8545 //no effect.
8546 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8547 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8548 break;
8549
8550 default:
8551 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8552
8553 }
8554 }
8555
8556 } //end if stretched, but not masked
8557 310 }
8558 else //not stretched
8559 {
8560
8561
2/2
✓ Branch 0 taken 113326 times.
✓ Branch 1 taken 17 times.
113343 if(masked) //if masked, but not stretched
8562 {
8563
8564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113326 times.
113326 if ( rot == 0 ) //if not rotated
8565 {
8566
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 113326 times.
113326 switch(mode)
8567 {
8568 case 1:
8569 //transparent
8570 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8571 draw_trans_sprite(newDest, subBmp, dx, dy);
8572 break;
8573
8574
8575 case 2:
8576 //pivot?
8577 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8578 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8579 //Pivoting requires two more args
8580 break;
8581
8582 case 3:
8583 //pivot + trans
8584 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8585 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8586 break;
8587
8588 case 4:
8589 //flip v
8590 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8591 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8592 break;
8593
8594 case 5:
8595 //trans + v flip
8596 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8597 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8598 break;
8599
8600 case 6:
8601 //pivot + v flip
8602 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8603 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8604 break;
8605
8606 case 8:
8607 //vlip h
8608 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8609 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8610 break;
8611
8612 case 9:
8613 //trans + h flip
8614 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8615 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8616 break;
8617
8618 case 10:
8619 //flip H and pivot
8620 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8621 //return error cannot pivot and h flip
8622 break;
8623
8624 case 12:
8625 //vh flip
8626 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8627 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8628 break;
8629
8630 case 13:
8631 //trans + vh flip
8632 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8633 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8634 break;
8635
8636 case 14:
8637 //pivot and vh flip
8638 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8639 //return error cannot both pivot and vh flip
8640 break;
8641
8642 case 16:
8643 //lit
8644 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8645 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8646 break;
8647
8648 case 18:
8649 //pivot, lit
8650 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8651 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8652 break;
8653
8654 case 20:
8655 //lit + v flip
8656 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8657 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8658 break;
8659
8660 case 22:
8661 //Pivot, vflip, lit
8662 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8663 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8664 break;
8665
8666 case 24:
8667 //lit + h flip
8668 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8669 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8670 break;
8671
8672 case 26:
8673 //pivot + lit + hflip
8674 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8675 //return error cannot pivot, lit, and flip
8676 break;
8677
8678 case 28:
8679 //lit + vh flip
8680 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8681 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8682 break;
8683
8684 case 32: //gouraud
8685 //Probably not wort supporting.
8686 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8687 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8688 break;
8689
8690 case 0:
8691 //no effect
8692 113326 masked_blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8693 113326 break;
8694
8695
8696 default:
8697 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8698
8699
8700 }
8701 113326 } //end if not rotated
8702
8703
1/2
✓ Branch 0 taken 113326 times.
✗ Branch 1 not taken.
113326 if ( rot != 0 ) //if rotated
8704 {
8705 switch(mode)
8706 {
8707 case 1:
8708 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //transparent
8709 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8710
8711 break;
8712
8713 case 2:
8714 //pivot?
8715 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8716 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8717 //Pivoting requires two more args
8718 break;
8719
8720 case 3:
8721 //pivot + trans
8722 //return an error, cannot both rotate and pivot
8723 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8724 break;
8725
8726 case 4:
8727 //flip v
8728 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8729 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8730 break;
8731
8732 case 5:
8733 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
8734 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8735 break;
8736
8737 case 6:
8738 //pivot + v flip
8739 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8740 //return an error, cannot both rotate and pivot
8741 break;
8742
8743 case 8:
8744 //flip h
8745 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8746 //return an error, cannot both rotate and flip H
8747 break;
8748
8749 case 9:
8750 //trans + h flip
8751 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8752 //return an error, cannot rotate and flip a trans sprite
8753 break;
8754
8755 case 10:
8756 //flip H and pivot
8757 //return error cannot pivot and h flip
8758 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8759 break;
8760
8761 case 12:
8762 //vh flip
8763 //return an error, cannot rotate and VH flip a trans sprite
8764 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8765 break;
8766
8767 case 13:
8768 //trans + vh flip
8769 //return an error, cannot rotate and VH flip a trans sprite
8770 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8771 break;
8772
8773 case 14:
8774 //pivot and vh flip
8775 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8776 //return error cannot both pivot and vh flip
8777 break;
8778
8779 case 16:
8780 //lit
8781 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8782 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8783 break;
8784
8785 case 18:
8786 //pivot, lit
8787 //return an error, cannot both rotate and pivot
8788 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8789 break;
8790
8791 case 20:
8792 //lit + vflip
8793 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8794 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8795 break;
8796
8797 case 22:
8798 //Pivot, vflip, lit
8799 //return an error, cannot both rotate and pivot
8800 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8801 break;
8802
8803 case 24:
8804 //lit + h flip
8805 //return an error, cannot both rotate and H flip
8806 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8807 break;
8808
8809 case 26:
8810 //pivot + lit + hflip
8811 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8812 //return error cannot pivot, lit, and flip
8813 break;
8814
8815 case 28:
8816 //lit + vh flip
8817 //return an error, cannot both rotate and VH flip
8818 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8819 break;
8820
8821 case 32: //gouraud
8822 //Probably not wort supporting.
8823 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8824 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8825 break;
8826
8827 case 0:
8828 //no effect.
8829 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8830 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8831 break;
8832
8833 default:
8834 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8835
8836 }
8837 } //end rtated, masked
8838 113326 } //end if masked
8839
8840 else //not masked, and not stretched; just blit
8841 {
8842
8843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if ( rot == 0 ) //if not rotated
8844 {
8845
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 17 times.
17 switch(mode)
8846 {
8847 case 1:
8848 //transparent
8849 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8850 draw_trans_sprite(newDest, subBmp, dx, dy);
8851 break;
8852
8853
8854 case 2:
8855 //pivot?
8856 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8857 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8858 //Pivoting requires two more args
8859 break;
8860
8861 case 3:
8862 //pivot + trans
8863 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8864 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8865 break;
8866
8867 case 4:
8868 //flip v
8869 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8870 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8871 break;
8872
8873 case 5:
8874 //trans + v flip
8875 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8876 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8877 break;
8878
8879 case 6:
8880 //pivot + v flip
8881 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8882 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8883 break;
8884
8885 case 8:
8886 //vlip h
8887 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8888 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8889 break;
8890
8891 case 9:
8892 //trans + h flip
8893 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8894 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8895 break;
8896
8897 case 10:
8898 //flip H and pivot
8899 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8900 //return error cannot pivot and h flip
8901 break;
8902
8903 case 12:
8904 //vh flip
8905 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8906 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8907 break;
8908
8909 case 13:
8910 //trans + vh flip
8911 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8912 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8913 break;
8914
8915 case 14:
8916 //pivot and vh flip
8917 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8918 //return error cannot both pivot and vh flip
8919 break;
8920
8921 case 16:
8922 //lit
8923 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8924 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8925 break;
8926
8927 case 18:
8928 //pivot, lit
8929 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8930 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8931 break;
8932
8933 case 20:
8934 //lit + v flip
8935 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8936 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8937 break;
8938
8939 case 22:
8940 //Pivot, vflip, lit
8941 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8942 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8943 break;
8944
8945 case 24:
8946 //lit + h flip
8947 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8948 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8949 break;
8950
8951 case 26:
8952 //pivot + lit + hflip
8953 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8954 //return error cannot pivot, lit, and flip
8955 break;
8956
8957 case 28:
8958 //lit + vh flip
8959 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8960 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8961 break;
8962
8963 case 32: //gouraud
8964 //Probably not wort supporting.
8965 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8966 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8967 break;
8968
8969 case 0:
8970 //no effect
8971 17 blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8972 17 break;
8973
8974
8975 default:
8976 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8977
8978
8979 }
8980 17 } //end if not rotated
8981
8982
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if ( rot != 0 ) //if rotated
8983 {
8984 switch(mode)
8985 {
8986 case 1:
8987 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);//transparent
8988 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8989
8990 break;
8991
8992 case 2:
8993 //pivot?
8994 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8995 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8996 //Pivoting requires two more args
8997 break;
8998
8999 case 3:
9000 //pivot + trans
9001 //return an error, cannot both rotate and pivot
9002 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9003 break;
9004
9005 case 4:
9006 //flip v
9007 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9008 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9009 break;
9010
9011 case 5:
9012 //trans + v flip
9013 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9014 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9015 break;
9016
9017 case 6:
9018 //pivot + v flip
9019 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9020 //return an error, cannot both rotate and pivot
9021 break;
9022
9023 case 8:
9024 //flip h
9025 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
9026 //return an error, cannot both rotate and flip H
9027 break;
9028
9029 case 9:
9030 //trans + h flip
9031 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
9032 //return an error, cannot rotate and flip a trans sprite
9033 break;
9034
9035 case 10:
9036 //flip H and pivot
9037 //return error cannot pivot and h flip
9038 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
9039 break;
9040
9041 case 12:
9042 //vh flip
9043 //return an error, cannot rotate and VH flip a trans sprite
9044 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9045 break;
9046
9047 case 13:
9048 //trans + vh flip
9049 //return an error, cannot rotate and VH flip a trans sprite
9050 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9051 break;
9052
9053 case 14:
9054 //pivot and vh flip
9055 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9056 //return error cannot both pivot and vh flip
9057 break;
9058
9059 case 16:
9060 //lit
9061 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9062 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9063 break;
9064
9065 case 18:
9066 //pivot, lit
9067 //return an error, cannot both rotate and pivot
9068 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9069 break;
9070
9071 case 20:
9072 //lit + vflip
9073 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9074 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9075 break;
9076
9077 case 22:
9078 //Pivot, vflip, lit
9079 //return an error, cannot both rotate and pivot
9080 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9081 break;
9082
9083 case 24:
9084 //lit + h flip
9085 //return an error, cannot both rotate and H flip
9086 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
9087 break;
9088
9089 case 26:
9090 //pivot + lit + hflip
9091 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
9092 //return error cannot pivot, lit, and flip
9093 break;
9094
9095 case 28:
9096 //lit + vh flip
9097 //return an error, cannot both rotate and VH flip
9098 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
9099 break;
9100
9101 case 32: //gouraud
9102 //Probably not wort supporting.
9103 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9104 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9105 break;
9106
9107 case 0:
9108 //no effect.
9109 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9110 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9111 break;
9112
9113 default:
9114 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
9115
9116 }
9117 } //end if rotated
9118 } //end if not masked
9119 } //end if not stretched
9120
9121 //cleanup
9122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113653 times.
113653 if(subBmp)
9123 {
9124 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
9125 destroy_bitmap(subBmp);
9126 }
9127
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 113650 times.
113653 if(newSource != destBMP)
9128 {
9129 3 destroy_bitmap(newSource);
9130 3 }
9131 113653 }
9132
9133 void do_tileblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool is_bmp, char const* funcstr)
9134 {
9135 /*
9136 //sdci[1]=layer
9137 //sdci[2]=tile
9138 //sdci[3]=cset
9139 //sdci[4]=sourcex
9140 //sdci[5]=sourcey
9141 //sdci[6]=sourcew
9142 //sdci[7]=sourceh
9143 //sdci[8]=destx
9144 //sdci[9]=desty
9145 //sdci[10]=destw
9146 //sdci[11]=desth
9147 //sdci[12]=rotation/angle
9148 //scdi[13] = pivot cx
9149 //sdci[14] = pivot cy
9150 //scdi[15] = effect flags
9151
9152 // ZScript-side constant values:
9153 const int32_t BITDX_NORMAL = 0;
9154 const int32_t BITDX_TRANS = 1; //Translucent
9155 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
9156 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
9157 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
9158 //Note: Some modes cannot be combined. if a combination is not supported, an error
9159 // detailing this will be shown in allegro.log.
9160
9161 //scdi[16] = litcolour
9162 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9163 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
9164
9165 //sdci[17]=mask
9166 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
9167
9168 */
9169
9170 int32_t tile = sdci[2]/10000;
9171 int32_t cset = WRAP_CS(sdci[3]/10000);
9172
9173 int32_t sx = sdci[4]/10000;
9174 int32_t sy = sdci[5]/10000;
9175 int32_t sw = sdci[6]/10000;
9176 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
9177 int32_t sh = sdci[7]/10000;
9178 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
9179 int32_t dx = sdci[8]/10000;
9180 int32_t dy = sdci[9]/10000;
9181 int32_t dw = sdci[10]/10000;
9182 int32_t dh = sdci[11]/10000;
9183 float rot = sdci[12]/10000;
9184 int32_t cx = sdci[13]/10000;
9185 int32_t cy = sdci[14]/10000;
9186 int32_t mode = sdci[15]/10000;
9187 int32_t litcolour = sdci[16]/10000;
9188 bool masked = (sdci[17] != 0);
9189
9190 int32_t ref = 0;
9191
9192 if ( is_bmp && (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
9193 //Do we need to also check the render target and do the same thing if the
9194 //dest == -2 and the render target is not RT_SCREEN?
9195 dx += xoffset;
9196 dy += yoffset;
9197
9198 BITMAP *destbmp = nullptr;
9199 if(is_bmp)
9200 {
9201 ref = sdci[DRAWCMD_BMP_TARGET];
9202
9203 if ( ref <= 0 )
9204 {
9205 Z_scripterrlog("%s wanted to use to an invalid dest bitmap id: %d. Aborting.\n", funcstr, ref);
9206 return;
9207 }
9208 destbmp = resolveScriptingBitmap(ref);
9209 if(!destbmp)
9210 {
9211 Z_message("Warning: %s dest bitmap %d contains invalid data or is not initialized.\n", ref);
9212 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
9213 return;
9214 }
9215 }
9216 else destbmp = bmp;
9217
9218 bool stretched = (sw != dw || sh != dh);
9219
9220 BITMAP* srcbmp = create_bitmap_ex(8, sw, sh);
9221 //Draw tiles to srcbmp
9222 {
9223 clear_bitmap(srcbmp);
9224 int tx = 0, ty = 0;
9225 if(sx < 0)
9226 tx = (sx-15)/16;
9227 else if(sx > 15)
9228 tx = sx/16;
9229 if(sy < 0)
9230 ty = (sy-15)/16;
9231 else if(sy > 15)
9232 ty = sy/16;
9233
9234 int gxoff = -wrap(sx,0,15), gyoff = -wrap(sy,0,15);
9235 for(int ix = 0; ix <= sw; ix += 16)
9236 {
9237 for(int iy = 0; iy <= sh; iy += 16)
9238 {
9239 int t = tile+(tx+ix/16);
9240 int rowdiff = TILEROW(t) - TILEROW(tile);
9241 t += rowdiff * (sh/16) * TILES_PER_ROW;
9242 t += (ty+iy/16)*TILES_PER_ROW;
9243 overtile16(srcbmp, t, ix+gxoff, iy+gyoff, cset, 0);
9244 }
9245 }
9246
9247 sx = sy = 0;
9248 }
9249
9250 BITMAP* subBmp = nullptr;
9251
9252 if(rot != 0 || mode != 0)
9253 {
9254 subBmp = create_bitmap_ex(8,destbmp->w, destbmp->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
9255 clear_bitmap(subBmp);
9256
9257 if(!subBmp)
9258 {
9259 Z_scripterrlog("%s failed to create a sub-bitmap to use for %s. Aborting.\n", funcstr, "rotation");
9260 return;
9261 }
9262 }
9263
9264 //dx = dx + xoffset; //don't do this here!
9265 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
9266
9267 if(stretched)
9268 {
9269 if(masked)
9270 { //stretched and masked
9271 if ( rot == 0 )
9272 { //if not rotated
9273 switch(mode)
9274 {
9275 case 1:
9276 //transparent
9277 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9278 draw_trans_sprite(destbmp, subBmp, dx, dy);
9279 break;
9280
9281
9282 case 2:
9283 //pivot?
9284 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9285 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9286 //Pivoting requires two more args
9287 break;
9288
9289 case 3:
9290 //pivot + trans
9291 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9292 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9293 break;
9294
9295 case 4:
9296 //flip v
9297 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9298 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9299 break;
9300
9301 case 5:
9302 //trans + v flip
9303 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9304 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9305 break;
9306
9307 case 6:
9308 //pivot + v flip
9309 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9310 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9311 break;
9312
9313 case 8:
9314 //vlip h
9315 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9316 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9317 break;
9318
9319 case 9:
9320 //trans + h flip
9321 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9322 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9323 break;
9324
9325 case 10:
9326 //flip H and pivot
9327 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9328 //return error cannot pivot and h flip
9329 break;
9330
9331 case 12:
9332 //vh flip
9333 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9334 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9335 break;
9336
9337 case 13:
9338 //trans + vh flip
9339 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9340 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9341 break;
9342
9343 case 14:
9344 //pivot and vh flip
9345 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9346 //return error cannot both pivot and vh flip
9347 break;
9348
9349 case 16:
9350 //lit
9351 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9352 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9353 break;
9354
9355 case 18:
9356 //pivot, lit
9357 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9358 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9359 break;
9360
9361 case 20:
9362 //lit + v flip
9363 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9364 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9365 break;
9366
9367 case 22:
9368 //Pivot, vflip, lit
9369 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9370 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9371 break;
9372
9373 case 24:
9374 //lit + h flip
9375 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9376 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9377 break;
9378
9379 case 26:
9380 //pivot + lit + hflip
9381 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9382 //return error cannot pivot, lit, and flip
9383 break;
9384
9385 case 28:
9386 //lit + vh flip
9387 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9388 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9389 break;
9390
9391 case 32: //gouraud
9392 //Probably not wort supporting.
9393 //masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9394 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9395 break;
9396
9397 case 0:
9398 //no effect
9399 masked_stretch_blit(srcbmp, destbmp, sx, sy, sw, sh, dx, dy, dw, dh);
9400 break;
9401
9402
9403 default:
9404 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9405
9406
9407 }
9408 } //end if not rotated
9409
9410 if ( rot != 0 ) //if rotated
9411 {
9412 switch(mode)
9413 {
9414 case 1:
9415 //transparent
9416 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9417 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9418
9419 break;
9420
9421 case 2:
9422 //pivot?
9423 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9424 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9425 //Pivoting requires two more args
9426 break;
9427
9428 case 3:
9429 //pivot + trans
9430 //return an error, cannot both rotate and pivot
9431 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9432 break;
9433
9434 case 4:
9435 //flip v
9436 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9437 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9438 break;
9439
9440 case 5:
9441 //trans + v flip
9442 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9443 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9444 break;
9445
9446 case 6:
9447 //pivot + v flip
9448 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9449 //return an error, cannot both rotate and pivot
9450 break;
9451
9452 case 8:
9453 //flip h
9454 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9455 //return an error, cannot both rotate and flip H
9456 break;
9457
9458 case 9:
9459 //trans + h flip
9460 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
9461 //return an error, cannot rotate and flip a trans sprite
9462 break;
9463
9464 case 10:
9465 //flip H and pivot
9466 //return error cannot pivot and h flip
9467 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9468 break;
9469
9470 case 12:
9471 //vh flip
9472 //return an error, cannot rotate and VH flip a trans sprite
9473 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9474 break;
9475
9476 case 13:
9477 //trans + vh flip
9478 //return an error, cannot rotate and VH flip a trans sprite
9479 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9480 break;
9481
9482 case 14:
9483 //pivot and vh flip
9484 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9485 //return error cannot both pivot and vh flip
9486 break;
9487
9488 case 16:
9489 //lit
9490 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9491 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9492 break;
9493
9494 case 18:
9495 //pivot, lit
9496 //return an error, cannot both rotate and pivot
9497 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9498 break;
9499
9500 case 20:
9501 //lit + vflip
9502 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9503 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9504 break;
9505
9506 case 22:
9507 //Pivot, vflip, lit
9508 //return an error, cannot both rotate and pivot
9509 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9510 break;
9511
9512 case 24:
9513 //lit + h flip
9514 //return an error, cannot both rotate and H flip
9515 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9516 break;
9517
9518 case 26:
9519 //pivot + lit + hflip
9520 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
9521 //return error cannot pivot, lit, and flip
9522 break;
9523
9524 case 28:
9525 //lit + vh flip
9526 //return an error, cannot both rotate and VH flip
9527 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9528 break;
9529
9530 case 32: //gouraud
9531 //Probably not wort supporting.
9532 //masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9533 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9534 break;
9535
9536 case 0:
9537 //no effect.
9538 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9539 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9540 break;
9541
9542 default:
9543 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9544
9545 }
9546 }
9547 } //end if stretched and masked
9548
9549 else //stretched, not masked
9550 {
9551
9552
9553 if ( rot == 0 ) //if not rotated
9554 {
9555 switch(mode)
9556 {
9557 case 1:
9558 //transparent
9559 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9560 draw_trans_sprite(destbmp, subBmp, dx, dy);
9561 break;
9562
9563
9564 case 2:
9565 //pivot?
9566 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9567 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9568 //Pivoting requires two more args
9569 break;
9570
9571 case 3:
9572 //pivot + trans
9573 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9574 pivot_sprite_trans(destbmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
9575 break;
9576
9577 case 4:
9578 //flip v
9579 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9580 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9581 break;
9582
9583 case 5:
9584 //trans + v flip
9585 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9586 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9587 break;
9588
9589 case 6:
9590 //pivot + v flip
9591 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9592 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9593 break;
9594
9595 case 8:
9596 //vlip h
9597 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9598 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9599 break;
9600
9601 case 9:
9602 //trans + h flip
9603 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9604 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9605 break;
9606
9607 case 10:
9608 //flip H and pivot
9609 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9610 //return error cannot pivot and h flip
9611 break;
9612
9613 case 12:
9614 //vh flip
9615 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9616 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9617 break;
9618
9619 case 13:
9620 //trans + vh flip
9621 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9622 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9623 break;
9624
9625 case 14:
9626 //pivot and vh flip
9627 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9628 //return error cannot both pivot and vh flip
9629 break;
9630
9631 case 16:
9632 //lit
9633 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9634 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9635 break;
9636
9637 case 18:
9638 //pivot, lit
9639 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9640 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9641 break;
9642
9643 case 20:
9644 //lit + v flip
9645 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9646 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9647 break;
9648
9649 case 22:
9650 //Pivot, vflip, lit
9651 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9652 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9653 break;
9654
9655 case 24:
9656 //lit + h flip
9657 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9658 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9659 break;
9660
9661 case 26:
9662 //pivot + lit + hflip
9663 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9664 //return error cannot pivot, lit, and flip
9665 break;
9666
9667 case 28:
9668 //lit + vh flip
9669 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9670 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9671 break;
9672
9673 case 32: //gouraud
9674 //Probably not wort supporting.
9675 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9676 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9677 break;
9678
9679 case 0:
9680 //no effect
9681 stretch_blit(srcbmp, destbmp, sx, sy, sw, sh, dx, dy, dw, dh);
9682 break;
9683
9684
9685 default:
9686 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9687
9688
9689 }
9690 } //end if not rotated
9691
9692 if ( rot != 0 ) //if rotated
9693 {
9694 switch(mode)
9695 {
9696 case 1:
9697 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9698 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9699
9700 break;
9701
9702 case 2:
9703 //pivot?
9704 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9705 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9706 //Pivoting requires two more args
9707 break;
9708
9709 case 3:
9710 //pivot + trans
9711 //return an error, cannot both rotate and pivot
9712 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9713 break;
9714
9715 case 4:
9716 //flip v
9717 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9718 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9719 break;
9720
9721 case 5:
9722 //trans + v flip
9723 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9724 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9725 break;
9726
9727 case 6:
9728 //pivot + v flip
9729 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9730 //return an error, cannot both rotate and pivot
9731 break;
9732
9733 case 8:
9734 //flip h
9735 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9736 //return an error, cannot both rotate and flip H
9737 break;
9738
9739 case 9:
9740 //trans + h flip
9741 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
9742 //return an error, cannot rotate and flip a trans sprite
9743 break;
9744
9745 case 10:
9746 //flip H and pivot
9747 //return error cannot pivot and h flip
9748 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9749 break;
9750
9751 case 12:
9752 //vh flip
9753 //return an error, cannot rotate and VH flip a trans sprite
9754 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9755 break;
9756
9757 case 13:
9758 //trans + vh flip
9759 //return an error, cannot rotate and VH flip a trans sprite
9760 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9761 break;
9762
9763 case 14:
9764 //pivot and vh flip
9765 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9766 //return error cannot both pivot and vh flip
9767 break;
9768
9769 case 16:
9770 //lit
9771 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9772 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9773 break;
9774
9775 case 18:
9776 //pivot, lit
9777 //return an error, cannot both rotate and pivot
9778 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9779 break;
9780
9781 case 20:
9782 //lit + vflip
9783 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9784 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9785 break;
9786
9787 case 22:
9788 //Pivot, vflip, lit
9789 //return an error, cannot both rotate and pivot
9790 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9791 break;
9792
9793 case 24:
9794 //lit + h flip
9795 //return an error, cannot both rotate and H flip
9796 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9797 break;
9798
9799 case 26:
9800 //pivot + lit + hflip
9801 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
9802 //return error cannot pivot, lit, and flip
9803 break;
9804
9805 case 28:
9806 //lit + vh flip
9807 //return an error, cannot both rotate and VH flip
9808 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9809 break;
9810
9811 case 32: //gouraud
9812 //Probably not wort supporting.
9813 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9814 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9815 break;
9816
9817 case 0:
9818 //no effect.
9819 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9820 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9821 break;
9822
9823 default:
9824 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9825
9826 }
9827 }
9828
9829 } //end if stretched, but not masked
9830 }
9831 else //not stretched
9832 {
9833
9834 if(masked) //if masked, but not stretched
9835 {
9836
9837 if ( rot == 0 ) //if not rotated
9838 {
9839 switch(mode)
9840 {
9841 case 1:
9842 //transparent
9843 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9844 draw_trans_sprite(destbmp, subBmp, dx, dy);
9845 break;
9846
9847
9848 case 2:
9849 //pivot?
9850 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9851 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9852 //Pivoting requires two more args
9853 break;
9854
9855 case 3:
9856 //pivot + trans
9857 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9858 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9859 break;
9860
9861 case 4:
9862 //flip v
9863 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9864 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9865 break;
9866
9867 case 5:
9868 //trans + v flip
9869 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9870 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9871 break;
9872
9873 case 6:
9874 //pivot + v flip
9875 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9876 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9877 break;
9878
9879 case 8:
9880 //vlip h
9881 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9882 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9883 break;
9884
9885 case 9:
9886 //trans + h flip
9887 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9888 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9889 break;
9890
9891 case 10:
9892 //flip H and pivot
9893 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9894 //return error cannot pivot and h flip
9895 break;
9896
9897 case 12:
9898 //vh flip
9899 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9900 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9901 break;
9902
9903 case 13:
9904 //trans + vh flip
9905 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9906 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9907 break;
9908
9909 case 14:
9910 //pivot and vh flip
9911 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9912 //return error cannot both pivot and vh flip
9913 break;
9914
9915 case 16:
9916 //lit
9917 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9918 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9919 break;
9920
9921 case 18:
9922 //pivot, lit
9923 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9924 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9925 break;
9926
9927 case 20:
9928 //lit + v flip
9929 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9930 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9931 break;
9932
9933 case 22:
9934 //Pivot, vflip, lit
9935 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9936 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9937 break;
9938
9939 case 24:
9940 //lit + h flip
9941 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9942 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9943 break;
9944
9945 case 26:
9946 //pivot + lit + hflip
9947 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9948 //return error cannot pivot, lit, and flip
9949 break;
9950
9951 case 28:
9952 //lit + vh flip
9953 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9954 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9955 break;
9956
9957 case 32: //gouraud
9958 //Probably not wort supporting.
9959 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9960 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9961 break;
9962
9963 case 0:
9964 //no effect
9965 masked_blit(srcbmp, destbmp, sx, sy, dx, dy, dw, dh);
9966 break;
9967
9968
9969 default:
9970 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9971
9972
9973 }
9974 } //end if not rotated
9975
9976 if ( rot != 0 ) //if rotated
9977 {
9978 switch(mode)
9979 {
9980 case 1:
9981 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
9982 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9983
9984 break;
9985
9986 case 2:
9987 //pivot?
9988 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9989 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9990 //Pivoting requires two more args
9991 break;
9992
9993 case 3:
9994 //pivot + trans
9995 //return an error, cannot both rotate and pivot
9996 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9997 break;
9998
9999 case 4:
10000 //flip v
10001 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10002 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10003 break;
10004
10005 case 5:
10006 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
10007 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10008 break;
10009
10010 case 6:
10011 //pivot + v flip
10012 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10013 //return an error, cannot both rotate and pivot
10014 break;
10015
10016 case 8:
10017 //flip h
10018 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10019 //return an error, cannot both rotate and flip H
10020 break;
10021
10022 case 9:
10023 //trans + h flip
10024 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
10025 //return an error, cannot rotate and flip a trans sprite
10026 break;
10027
10028 case 10:
10029 //flip H and pivot
10030 //return error cannot pivot and h flip
10031 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10032 break;
10033
10034 case 12:
10035 //vh flip
10036 //return an error, cannot rotate and VH flip a trans sprite
10037 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10038 break;
10039
10040 case 13:
10041 //trans + vh flip
10042 //return an error, cannot rotate and VH flip a trans sprite
10043 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10044 break;
10045
10046 case 14:
10047 //pivot and vh flip
10048 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10049 //return error cannot both pivot and vh flip
10050 break;
10051
10052 case 16:
10053 //lit
10054 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10055 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10056 break;
10057
10058 case 18:
10059 //pivot, lit
10060 //return an error, cannot both rotate and pivot
10061 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10062 break;
10063
10064 case 20:
10065 //lit + vflip
10066 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10067 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10068 break;
10069
10070 case 22:
10071 //Pivot, vflip, lit
10072 //return an error, cannot both rotate and pivot
10073 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10074 break;
10075
10076 case 24:
10077 //lit + h flip
10078 //return an error, cannot both rotate and H flip
10079 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10080 break;
10081
10082 case 26:
10083 //pivot + lit + hflip
10084 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
10085 //return error cannot pivot, lit, and flip
10086 break;
10087
10088 case 28:
10089 //lit + vh flip
10090 //return an error, cannot both rotate and VH flip
10091 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10092 break;
10093
10094 case 32: //gouraud
10095 //Probably not wort supporting.
10096 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
10097 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10098 break;
10099
10100 case 0:
10101 //no effect.
10102 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10103 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10104 break;
10105
10106 default:
10107 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10108
10109 }
10110 } //end rtated, masked
10111 } //end if masked
10112
10113 else //not masked, and not stretched; just blit
10114 {
10115
10116 if ( rot == 0 ) //if not rotated
10117 {
10118 switch(mode)
10119 {
10120 case 1:
10121 //transparent
10122 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10123 draw_trans_sprite(destbmp, subBmp, dx, dy);
10124 break;
10125
10126
10127 case 2:
10128 //pivot?
10129 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10130 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10131 //Pivoting requires two more args
10132 break;
10133
10134 case 3:
10135 //pivot + trans
10136 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10137 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10138 break;
10139
10140 case 4:
10141 //flip v
10142 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10143 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
10144 break;
10145
10146 case 5:
10147 //trans + v flip
10148 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10149 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
10150 break;
10151
10152 case 6:
10153 //pivot + v flip
10154 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10155 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10156 break;
10157
10158 case 8:
10159 //vlip h
10160 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10161 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
10162 break;
10163
10164 case 9:
10165 //trans + h flip
10166 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10167 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
10168 break;
10169
10170 case 10:
10171 //flip H and pivot
10172 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10173 //return error cannot pivot and h flip
10174 break;
10175
10176 case 12:
10177 //vh flip
10178 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10179 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
10180 break;
10181
10182 case 13:
10183 //trans + vh flip
10184 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10185 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
10186 break;
10187
10188 case 14:
10189 //pivot and vh flip
10190 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10191 //return error cannot both pivot and vh flip
10192 break;
10193
10194 case 16:
10195 //lit
10196 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10197 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
10198 break;
10199
10200 case 18:
10201 //pivot, lit
10202 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10203 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
10204 break;
10205
10206 case 20:
10207 //lit + v flip
10208 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10209 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
10210 break;
10211
10212 case 22:
10213 //Pivot, vflip, lit
10214 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10215 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
10216 break;
10217
10218 case 24:
10219 //lit + h flip
10220 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10221 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
10222 break;
10223
10224 case 26:
10225 //pivot + lit + hflip
10226 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
10227 //return error cannot pivot, lit, and flip
10228 break;
10229
10230 case 28:
10231 //lit + vh flip
10232 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10233 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
10234 break;
10235
10236 case 32: //gouraud
10237 //Probably not wort supporting.
10238 //blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10239 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10240 break;
10241
10242 case 0:
10243 //no effect
10244 blit(srcbmp, destbmp, sx, sy, dx, dy, dw, dh);
10245 break;
10246
10247
10248 default:
10249 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10250
10251
10252 }
10253 } //end if not rotated
10254
10255 if ( rot != 0 ) //if rotated
10256 {
10257 switch(mode)
10258 {
10259 case 1:
10260 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
10261 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10262
10263 break;
10264
10265 case 2:
10266 //pivot?
10267 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10268 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10269 //Pivoting requires two more args
10270 break;
10271
10272 case 3:
10273 //pivot + trans
10274 //return an error, cannot both rotate and pivot
10275 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10276 break;
10277
10278 case 4:
10279 //flip v
10280 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10281 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10282 break;
10283
10284 case 5:
10285 //trans + v flip
10286 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10287 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10288 break;
10289
10290 case 6:
10291 //pivot + v flip
10292 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10293 //return an error, cannot both rotate and pivot
10294 break;
10295
10296 case 8:
10297 //flip h
10298 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10299 //return an error, cannot both rotate and flip H
10300 break;
10301
10302 case 9:
10303 //trans + h flip
10304 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
10305 //return an error, cannot rotate and flip a trans sprite
10306 break;
10307
10308 case 10:
10309 //flip H and pivot
10310 //return error cannot pivot and h flip
10311 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10312 break;
10313
10314 case 12:
10315 //vh flip
10316 //return an error, cannot rotate and VH flip a trans sprite
10317 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10318 break;
10319
10320 case 13:
10321 //trans + vh flip
10322 //return an error, cannot rotate and VH flip a trans sprite
10323 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10324 break;
10325
10326 case 14:
10327 //pivot and vh flip
10328 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10329 //return error cannot both pivot and vh flip
10330 break;
10331
10332 case 16:
10333 //lit
10334 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10335 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10336 break;
10337
10338 case 18:
10339 //pivot, lit
10340 //return an error, cannot both rotate and pivot
10341 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10342 break;
10343
10344 case 20:
10345 //lit + vflip
10346 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10347 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10348 break;
10349
10350 case 22:
10351 //Pivot, vflip, lit
10352 //return an error, cannot both rotate and pivot
10353 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10354 break;
10355
10356 case 24:
10357 //lit + h flip
10358 //return an error, cannot both rotate and H flip
10359 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10360 break;
10361
10362 case 26:
10363 //pivot + lit + hflip
10364 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
10365 //return error cannot pivot, lit, and flip
10366 break;
10367
10368 case 28:
10369 //lit + vh flip
10370 //return an error, cannot both rotate and VH flip
10371 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10372 break;
10373
10374 case 32: //gouraud
10375 //Probably not wort supporting.
10376 //blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10377 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10378 break;
10379
10380 case 0:
10381 //no effect.
10382 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10383 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10384 break;
10385
10386 default:
10387 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10388
10389 }
10390 } //end if rotated
10391 } //end if not masked
10392 } //end if not stretched
10393
10394 //cleanup
10395 if(subBmp)
10396 {
10397 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
10398 destroy_bitmap(subBmp);
10399 }
10400 destroy_bitmap(srcbmp);
10401 }
10402
10403 void do_comboblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool is_bmp)
10404 {
10405 //sdci[2]: combo -> tile
10406 int cid = sdci[2]/10000;
10407 if(unsigned(cid) >= MAXCOMBOS)
10408 {
10409 Z_scripterrlog("ComboBlit tried to draw invalid combo id '%d'\n", cid);
10410 return;
10411 }
10412 sdci[2] = GET_DRAWING_COMBO(cid).tile * 10000;
10413 do_tileblit(bmp, sdci, xoffset, yoffset, is_bmp, "ComboBlit()");
10414 }
10415
10416 void bmp_do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
10417 {
10418
10419 //sdci[1]=layer
10420 //sdci[2]=pos[12]
10421 //sdci[3]=uv[8]
10422 //sdci[4]=color[4]
10423 //sdci[5]=size[2]
10424 //sdci[6]=flip
10425 //sdci[7]=tile/combo
10426 //sdci[8]=polytype
10427 //sdci[9] = other bitmap as texture
10428 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10429 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
10430 {
10431 Z_scripterrlog("bitmap->Quad3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
10432 return;
10433 }
10434 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10435 if ( refbmp == NULL ) return;
10436
10437 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
10438
10439 if(!v_ptr)
10440 {
10441 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
10442 return;
10443 }
10444
10445 std::vector<int32_t> &v = *v_ptr;
10446
10447 if(v.empty())
10448 return;
10449
10450 int32_t* pos = &v[0];
10451 int32_t* uv = &v[12];
10452 int32_t* col = &v[20];
10453 int32_t* size = &v[24];
10454
10455 int32_t w = size[0]; //magic numerical constants... yuck.
10456 int32_t h = size[1];
10457 int32_t flip = (sdci[6]/10000)&3;
10458 int32_t tile = sdci[7]/10000;
10459 int32_t polytype = sdci[8]/10000;
10460 int32_t quad_render_source = sdci[9];
10461 Z_scripterrlog("Quad3D texture is %d\n", quad_render_source);
10462
10463 polytype = vbound(polytype, 0, 14);
10464
10465 int32_t tex_width = w*16;
10466 int32_t tex_height = h*16;
10467
10468 bool mustDestroyBmp = false;
10469 BITMAP *tex=NULL;
10470
10471
10472 bool tex_is_bitmap = ( sdci[9] != 0 );
10473 //Z_scripterrlog("sdci[9] is %d\n", quad_render_source);
10474 //Z_scripterrlog("sdci[DRAWCMD_BMP_TARGET] is %d\n", sdci[DRAWCMD_BMP_TARGET]);
10475 BITMAP *bmptexture;
10476
10477 if ( tex_is_bitmap ) bmptexture = resolveScriptingBitmap(quad_render_source);
10478
10479 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10480
10481
10482 if ( !tex_is_bitmap )
10483 {
10484 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
10485
10486 if(!tex)
10487 {
10488 mustDestroyBmp = true;
10489 tex = create_bitmap_ex(8, tex_width, tex_height);
10490 clear_bitmap(tex);
10491 }
10492 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
10493 {
10494 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
10495 return; //non power of two error
10496 }
10497 if(tile > 0) // TILE
10498 {
10499 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
10500 }
10501 else // COMBO
10502 {
10503 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
10504 const int32_t tiletodraw = combo_tile(c, 0, 0);
10505 flip = flip ^ c.flip;
10506
10507 if(!(c.animflags & AF_EDITOR_ONLY))
10508 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
10509 }
10510
10511 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10512 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10513 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10514 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
10515
10516 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
10517 if(mustDestroyBmp)
10518 destroy_bitmap(tex);
10519 }
10520 else
10521 {
10522
10523 if ( !bmptexture )
10524 {
10525 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Quad3D()");
10526 tex_is_bitmap = 0;
10527 return;
10528 }
10529 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10530 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10531 if ( !isPowerOfTwo(h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
10532 if ( !isPowerOfTwo(w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
10533
10534 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10535 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10536 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10537 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
10538
10539 BITMAP *foo = create_bitmap_ex(8, 256, 176);
10540
10541 //quad3d_f(refbmp, polytype, foo, &V1, &V2, &V3, &V4);
10542 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
10543 destroy_bitmap(foo);
10544
10545 }
10546
10547
10548
10549 }
10550
10551
10552
10553 void bmp_do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
10554 {
10555 //sdci[1]=layer
10556 //sdci[2]=pos[9]
10557 //sdci[3]=uv[6]
10558 //sdci[4]=color[3]
10559 //sdci[5]=size[2]
10560 //sdci[6]=flip
10561 //sdci[7]=tile/combo
10562 //sdci[8]=polytype
10563 //sdci[9] bitmap as texture
10564 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10565 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
10566 {
10567 Z_scripterrlog("bitmap->Triangle3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
10568 return;
10569 }
10570 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10571 if ( refbmp == NULL ) return;
10572
10573 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
10574
10575 if(!v_ptr)
10576 {
10577 al_trace("bitmap->Triangle3d: Vector pointer is null! Internal error. \n");
10578 return;
10579 }
10580
10581 std::vector<int32_t> &v = *v_ptr;
10582
10583 if(v.empty())
10584 return;
10585
10586 int32_t* pos = &v[0];
10587 int32_t* uv = &v[9];
10588 int32_t* col = &v[15];
10589 int32_t* size = &v[18];
10590
10591 int32_t w = size[0]; //magic numerical constants... yuck.
10592 int32_t h = size[1];
10593 int32_t flip = (sdci[6]/10000)&3;
10594 int32_t tile = sdci[7]/10000;
10595 int32_t polytype = sdci[8]/10000;
10596 int32_t quad_render_source = sdci[9];
10597 polytype = vbound(polytype, 0, 14);
10598
10599 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
10600 {
10601 Z_message("bitmap->Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
10602 return; //non power of two error
10603 }
10604
10605 int32_t tex_width = w*16;
10606 int32_t tex_height = h*16;
10607
10608 bool mustDestroyBmp = false;
10609 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
10610
10611 if(!tex)
10612 {
10613 mustDestroyBmp = true;
10614 tex = create_bitmap_ex(8, tex_width, tex_height);
10615 clear_bitmap(tex);
10616 }
10617
10618 bool tex_is_bitmap = ( sdci[9] != 0 );
10619 BITMAP *bmptexture=NULL;
10620 if ( tex_is_bitmap )
10621 {
10622 bmptexture = resolveScriptingBitmap(quad_render_source);
10623 if ( !bmptexture )
10624 {
10625 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
10626 tex_is_bitmap = 0;
10627 }
10628 }
10629
10630 if ( !tex_is_bitmap )
10631 {
10632 if(tile > 0) // TILE
10633 {
10634 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
10635 }
10636 else // COMBO
10637 {
10638 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
10639 const int32_t tiletodraw = combo_tile(c, 0, 0);
10640 flip = flip ^ c.flip;
10641
10642 if(!(c.animflags & AF_EDITOR_ONLY))
10643 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
10644 }
10645
10646 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10647 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10648 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10649
10650 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
10651 }
10652 else
10653 {
10654 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10655 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10656 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
10657 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
10658
10659 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10660 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10661 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10662
10663 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
10664
10665
10666 }
10667 if(mustDestroyBmp)
10668 destroy_bitmap(tex);
10669
10670 }
10671
10672
10673 bool is_layer_transparent(const mapscr& m, int32_t layer)
10674 {
10675 layer = vbound(layer, 0, 5);
10676 return m.layeropacity[layer] == 128;
10677 }
10678
10679 4513893 mapscr *getmapscreen(int32_t map_index, int32_t screen, int32_t layer) //returns NULL for invalid or non-existent layer
10680 {
10681 mapscr *base_scr;
10682 4513893 int32_t index = map_index*MAPSCRS+screen;
10683
10684
2/4
✓ Branch 0 taken 4513893 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4513893 times.
4513893 if((uint32_t)layer > 6 || (uint32_t)index >= TheMaps.size())
10685 return NULL;
10686
10687
2/2
✓ Branch 0 taken 3579197 times.
✓ Branch 1 taken 934696 times.
4513893 if(layer != 0)
10688 {
10689 934696 layer = layer - 1;
10690
10691 934696 base_scr=&(TheMaps[index]);
10692
10693
2/2
✓ Branch 0 taken 842046 times.
✓ Branch 1 taken 92650 times.
934696 if(base_scr->layermap[layer]==0)
10694 92650 return NULL;
10695
10696 842046 index=(base_scr->layermap[layer]-1)*MAPSCRS+base_scr->layerscreen[layer];
10697
10698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 842046 times.
842046 if((uint32_t)index >= TheMaps.size()) // Might as well make sure
10699 return NULL;
10700 842046 }
10701
10702 4421243 return &(TheMaps[index]);
10703 4513893 }
10704
10705 659237800 static bool transparent_combo(int32_t id)
10706 {
10707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 659237800 times.
659237800 if(unsigned(id) >= MAXCOMBOS) return false;
10708 659237800 return bool(combobuf[id].animflags & AF_TRANSPARENT);
10709 659237800 }
10710
10711 199800 void draw_mapscr(BITMAP *b, const mapscr& m, int32_t x, int32_t y, bool transparent)
10712 {
10713
2/2
✓ Branch 0 taken 35164800 times.
✓ Branch 1 taken 199800 times.
35364600 for(int32_t i(0); i < 176; ++i)
10714 {
10715 35164800 const int32_t x2 = ((i&15)<<4) + x;
10716 35164800 const int32_t y2 = (i&0xF0) + y;
10717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164800 times.
35164800 if(combobuf[m.data[i]].animflags & AF_EDITOR_ONLY) continue;
10718
10719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164800 times.
35164800 if(transparent != transparent_combo(m.data[i]))
10720 {
10721 overcomboblocktranslucent(b, x2, y2, m.data[i], m.cset[i], 1, 1, 128);
10722 }
10723 else
10724 {
10725 35164800 overcomboblock(b, x2, y2, m.data[i], m.cset[i], 1, 1);
10726 }
10727 35164800 }
10728 199800 }
10729
10730 void draw_map_solidity(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10731 {
10732 BITMAP* square = create_bitmap_ex(8,16,16);
10733
10734 for(int32_t i(0); i < 176; ++i)
10735 {
10736 const int32_t x2 = ((i&15)<<4) + x;
10737 const int32_t y2 = (i&0xF0) + y;
10738 //Blit the palette index of the solidity value.
10739 clear_to_color(square,(combobuf[m.data[i]].walk&15));
10740 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10741 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10742 }
10743 destroy_bitmap(square);
10744 }
10745
10746 void do_bmpdrawscreen_solidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10747 {
10748 //sdci[1]=layer
10749 //sdci[2]=map
10750 //sdci[3]=screen
10751 //sdci[4]=x
10752 //sdci[5]=y
10753 //sdci[6]=rotation
10754 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10755
10756 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10757 if ( refbmp == NULL ) return;
10758
10759 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10760
10761 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10762 int32_t screen = sdci[3]/10000;
10763 int32_t x = sdci[4]/10000;
10764 int32_t y = sdci[5]/10000;
10765 int32_t x1 = x + xoffset;
10766 int32_t y1 = y + yoffset;
10767 int32_t rotation = sdci[6]/10000;
10768 uint32_t index = (uint32_t)map_screen_index(map, screen);
10769
10770 if(index >= TheMaps.size())
10771 {
10772 al_trace("DrawScreen: invalid map or screen index. \n");
10773 return;
10774 }
10775
10776 const mapscr & m = TheMaps[index];
10777
10778
10779 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10780 if ( refbmp == NULL ) return;
10781
10782 if(rotation != 0)
10783 b = script_drawing_commands.AquireSubBitmap(256, 176);
10784
10785 //draw layer 0
10786 draw_map_solidity(b, m, x1, y1);
10787 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10788 {
10789 for(int32_t i(0); i < 6; ++i)
10790 {
10791 if(m.layermap[i] == 0) continue;
10792
10793 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10794
10795 if(layer_screen_index >= TheMaps.size())
10796 continue;
10797
10798 //draw valid layers
10799 draw_map_solidity(b, TheMaps[ layer_screen_index ], x1, y1);
10800 }
10801 }
10802
10803 if(rotation != 0) // rotate
10804 {
10805 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10806 script_drawing_commands.ReleaseSubBitmap(b);
10807 }
10808 }
10809
10810 void draw_map_solid(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10811 {
10812 BITMAP* square = create_bitmap_ex(8,16,16);
10813 BITMAP* subsquare = create_bitmap_ex(8,16,16);
10814 clear_to_color(subsquare,1);
10815
10816 for(int32_t i(0); i < 176; ++i)
10817 {
10818 const int32_t x2 = ((i&15)<<4) + x;
10819 const int32_t y2 = (i&0xF0) + y;
10820 //Blit the palette index of the solidity value.
10821 clear_bitmap(square);
10822 int32_t sol = (combobuf[m.data[i]].walk);
10823 if ( sol & 1 )
10824 {
10825 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
10826 }
10827 if ( sol & 2 )
10828 {
10829 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
10830 }
10831 if ( sol & 4 )
10832 {
10833 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
10834 }
10835 if ( sol &8 ) {
10836 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
10837 }
10838
10839 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10840 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10841 }
10842 destroy_bitmap(square);
10843 destroy_bitmap(subsquare);
10844 }
10845
10846 void do_bmpdrawscreen_solidr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10847 {
10848 //sdci[1]=layer
10849 //sdci[2]=map
10850 //sdci[3]=screen
10851 //sdci[4]=x
10852 //sdci[5]=y
10853 //sdci[6]=rotation
10854 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10855
10856 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10857 if ( refbmp == NULL ) return;
10858
10859 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10860
10861 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10862 int32_t screen = sdci[3]/10000;
10863 int32_t x = sdci[4]/10000;
10864 int32_t y = sdci[5]/10000;
10865 int32_t x1 = x + xoffset;
10866 int32_t y1 = y + yoffset;
10867 int32_t rotation = sdci[6]/10000;
10868
10869 uint32_t index = (uint32_t)map_screen_index(map, screen);
10870
10871 if(index >= TheMaps.size())
10872 {
10873 al_trace("DrawScreen: invalid map or screen index. \n");
10874 return;
10875 }
10876
10877 const mapscr & m = TheMaps[index];
10878
10879
10880 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10881 if ( refbmp == NULL ) return;
10882
10883 if(rotation != 0)
10884 b = script_drawing_commands.AquireSubBitmap(256, 176);
10885
10886 //draw layer 0
10887 draw_map_solid(b, m, x1, y1);
10888
10889 for(int32_t i(0); i < 6; ++i) //This one doesn't need the QR; it works just fine.
10890 {
10891 if(m.layermap[i] == 0) continue;
10892
10893 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10894
10895 if(layer_screen_index >= TheMaps.size())
10896 continue;
10897
10898 //draw valid layers
10899 draw_map_solid(b, TheMaps[ layer_screen_index ], x1, y1);
10900 }
10901
10902 if(rotation != 0) // rotate
10903 {
10904 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10905 script_drawing_commands.ReleaseSubBitmap(b);
10906 }
10907 }
10908
10909 1024 void draw_map_cflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10910 {
10911 1024 BITMAP* square = create_bitmap_ex(8,16,16);
10912
10913
2/2
✓ Branch 0 taken 180224 times.
✓ Branch 1 taken 1024 times.
181248 for(int32_t i(0); i < 176; ++i)
10914 {
10915 180224 const int32_t x2 = ((i&15)<<4) + x;
10916 180224 const int32_t y2 = (i&0xF0) + y;
10917 //Blit the palette index of the solidity value.
10918 180224 clear_to_color(square,m.sflag[i]);
10919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180224 times.
180224 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10920 180224 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10921 180224 }
10922 1024 destroy_bitmap(square);
10923 1024 }
10924
10925 1024 void do_bmpdrawscreen_cflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10926 {
10927 //sdci[1]=layer
10928 //sdci[2]=map
10929 //sdci[3]=screen
10930 //sdci[4]=x
10931 //sdci[5]=y
10932 //sdci[6]=rotation
10933 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10934
10935 1024 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10936
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
10937
10938
2/4
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
1024 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10939
10940 1024 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10941 1024 int32_t screen = sdci[3]/10000;
10942 1024 int32_t x = sdci[4]/10000;
10943 1024 int32_t y = sdci[5]/10000;
10944 1024 int32_t x1 = x + xoffset;
10945 1024 int32_t y1 = y + yoffset;
10946 1024 int32_t rotation = sdci[6]/10000;
10947
10948 1024 uint32_t index = (uint32_t)map_screen_index(map, screen);
10949
10950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(index >= TheMaps.size())
10951 {
10952 al_trace("DrawScreen: invalid map or screen index. \n");
10953 return;
10954 }
10955
10956 1024 const mapscr & m = TheMaps[index];
10957
10958
10959 1024 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10960
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
10961
10962
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0)
10963 b = script_drawing_commands.AquireSubBitmap(256, 176);
10964
10965 //draw layer 0
10966 1024 draw_map_cflag(b, m, x1, y1);
10967
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10968 {
10969 for(int32_t i(0); i < 6; ++i)
10970 {
10971 if(m.layermap[i] == 0) continue;
10972
10973 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10974
10975 if(layer_screen_index >= TheMaps.size())
10976 continue;
10977
10978 //draw valid layers
10979 draw_map_cflag(b, TheMaps[ layer_screen_index ], x1, y1);
10980 }
10981 }
10982
10983
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0) // rotate
10984 {
10985 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10986 script_drawing_commands.ReleaseSubBitmap(b);
10987 }
10988 1024 }
10989
10990
10991 void draw_map_combotype(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10992 {
10993 BITMAP* square = create_bitmap_ex(8,16,16);
10994
10995 for(int32_t i(0); i < 176; ++i)
10996 {
10997 const int32_t x2 = ((i&15)<<4) + x;
10998 const int32_t y2 = (i&0xF0) + y;
10999 //Blit the palette index of the solidity value.
11000 clear_to_color(square,(combobuf[m.data[i]].type));
11001 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
11002 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
11003 }
11004 destroy_bitmap(square);
11005 }
11006
11007 void do_bmpdrawscreen_ctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11008 {
11009 //sdci[1]=layer
11010 //sdci[2]=map
11011 //sdci[3]=screen
11012 //sdci[4]=x
11013 //sdci[5]=y
11014 //sdci[6]=rotation
11015 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11016
11017 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11018 if ( refbmp == NULL ) return;
11019
11020 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11021
11022 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11023 int32_t screen = sdci[3]/10000;
11024 int32_t x = sdci[4]/10000;
11025 int32_t y = sdci[5]/10000;
11026 int32_t x1 = x + xoffset;
11027 int32_t y1 = y + yoffset;
11028 int32_t rotation = sdci[6]/10000;
11029
11030 uint32_t index = (uint32_t)map_screen_index(map, screen);
11031
11032 if(index >= TheMaps.size())
11033 {
11034 al_trace("DrawScreen: invalid map or screen index. \n");
11035 return;
11036 }
11037
11038 const mapscr & m = TheMaps[index];
11039
11040
11041 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11042 if ( refbmp == NULL ) return;
11043
11044 if(rotation != 0)
11045 b = script_drawing_commands.AquireSubBitmap(256, 176);
11046
11047 //draw layer 0
11048 draw_map_combotype(b, m, x1, y1);
11049
11050 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
11051 {
11052 for(int32_t i(0); i < 6; ++i)
11053 {
11054 if(m.layermap[i] == 0) continue;
11055
11056 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11057
11058 if(layer_screen_index >= TheMaps.size())
11059 continue;
11060
11061 //draw valid layers
11062 draw_map_combotype(b, TheMaps[ layer_screen_index ], x1, y1);
11063 }
11064 }
11065
11066 if(rotation != 0) // rotate
11067 {
11068 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11069 script_drawing_commands.ReleaseSubBitmap(b);
11070 }
11071 }
11072
11073
11074 void draw_map_comboiflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
11075 {
11076 BITMAP* square = create_bitmap_ex(8,16,16);
11077
11078 for(int32_t i(0); i < 176; ++i)
11079 {
11080 const int32_t x2 = ((i&15)<<4) + x;
11081 const int32_t y2 = (i&0xF0) + y;
11082 //Blit the palette index of the solidity value.
11083 clear_to_color(square,(combobuf[m.data[i]].flag));
11084 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
11085 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
11086 }
11087 destroy_bitmap(square);
11088 }
11089
11090 void do_bmpdrawscreen_ciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11091 {
11092 //sdci[1]=layer
11093 //sdci[2]=map
11094 //sdci[3]=screen
11095 //sdci[4]=x
11096 //sdci[5]=y
11097 //sdci[6]=rotation
11098 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11099
11100 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11101 if ( refbmp == NULL ) return;
11102
11103 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11104
11105 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11106 int32_t screen = sdci[3]/10000;
11107 int32_t x = sdci[4]/10000;
11108 int32_t y = sdci[5]/10000;
11109 int32_t x1 = x + xoffset;
11110 int32_t y1 = y + yoffset;
11111 int32_t rotation = sdci[6]/10000;
11112
11113 uint32_t index = (uint32_t)map_screen_index(map, screen);
11114
11115 if(index >= TheMaps.size())
11116 {
11117 al_trace("DrawScreen: invalid map or screen index. \n");
11118 return;
11119 }
11120
11121 const mapscr & m = TheMaps[index];
11122
11123
11124 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11125 if ( refbmp == NULL ) return;
11126
11127 if(rotation != 0)
11128 b = script_drawing_commands.AquireSubBitmap(256, 176);
11129
11130 //draw layer 0
11131 draw_map_comboiflag(b, m, x1, y1);
11132
11133 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
11134 {
11135 for(int32_t i(0); i < 6; ++i)
11136 {
11137 if(m.layermap[i] == 0) continue;
11138
11139 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11140
11141 if(layer_screen_index >= TheMaps.size())
11142 continue;
11143
11144 //draw valid layers
11145 draw_map_comboiflag(b, TheMaps[ layer_screen_index ], x1, y1);
11146 }
11147 }
11148
11149 if(rotation != 0) // rotate
11150 {
11151 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11152 script_drawing_commands.ReleaseSubBitmap(b);
11153 }
11154 }
11155
11156 4370235 void do_drawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11157 {
11158 //sdci[1]=layer
11159 //sdci[2]=map
11160 //sdci[3]=screen
11161 //sdci[4]=layer
11162 //sdci[5]=x
11163 //sdci[6]=y
11164 //sdci[7]=rotation
11165 //sdci[8]=opacity
11166
11167 4370235 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11168 4370235 int32_t screen = sdci[3]/10000;
11169 4370235 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11170 4370235 int32_t x = sdci[5]/10000;
11171 4370235 int32_t y = sdci[6]/10000;
11172 4370235 int32_t x1 = x + xoffset;
11173 4370235 int32_t y1 = y + yoffset;
11174 4370235 int32_t rotation = sdci[7]/10000;
11175 4370235 int32_t opacity = sdci[8]/10000;
11176
11177 4370235 uint32_t index = (uint32_t)map_screen_index(map, screen);
11178 4370235 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11179
11180
2/2
✓ Branch 0 taken 4318301 times.
✓ Branch 1 taken 51934 times.
4370235 if(!m) //no need to log it.
11181 51934 return;
11182
11183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4318301 times.
4318301 if(index >= TheMaps.size())
11184 {
11185 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11186 return;
11187 }
11188
11189 4318301 const mapscr & l = *m;
11190
11191 4318301 BITMAP* b = bmp;
11192
11193
1/2
✓ Branch 0 taken 4318301 times.
✗ Branch 1 not taken.
4318301 if(rotation != 0)
11194 b = script_drawing_commands.AquireSubBitmap(256, 176);
11195
11196
11197 4318301 const int32_t maxX = isOffScreen ? 512 : 256;
11198
2/2
✓ Branch 0 taken 4298918 times.
✓ Branch 1 taken 19383 times.
4318301 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11199 4318301 bool transparent = opacity <= 128;
11200
11201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4318301 times.
4318301 if(rotation != 0) // rotate
11202 {
11203 draw_mapscr(b, l, x1, y1, transparent);
11204
11205 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11206 script_drawing_commands.ReleaseSubBitmap(b);
11207 }
11208 else
11209 {
11210
2/2
✓ Branch 0 taken 760020976 times.
✓ Branch 1 taken 4318301 times.
764339277 for(int32_t i(0); i < 176; ++i)
11211 {
11212 760020976 const int32_t x2 = ((i&15)<<4) + x1;
11213 760020976 const int32_t y2 = (i&0xF0) + y1;
11214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760020976 times.
760020976 if(combobuf[l.data[i]].animflags & AF_EDITOR_ONLY) continue;
11215
11216
7/8
✓ Branch 0 taken 669516342 times.
✓ Branch 1 taken 90504634 times.
✓ Branch 2 taken 669516342 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 615110950 times.
✓ Branch 5 taken 54405392 times.
✓ Branch 6 taken 9155742 times.
✓ Branch 7 taken 605955208 times.
760020976 if(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY) //in clipping rect
11217 {
11218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 605955208 times.
605955208 if(opacity < 128 != transparent_combo(l.data[i]))
11219 {
11220 overcomboblocktranslucent(b, x2, y2, l.data[i], l.cset[i], 1, 1, 128);
11221 }
11222 else
11223 {
11224 605955208 overcomboblock(b, x2, y2, l.data[i], l.cset[i], 1, 1);
11225 }
11226 605955208 }
11227 760020976 }
11228 }
11229
11230 //putscr
11231 4370235 }
11232
11233
11234
11235 50406 void do_drawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11236 {
11237 //sdci[1]=layer
11238 //sdci[2]=map
11239 //sdci[3]=screen
11240 //sdci[4]=x
11241 //sdci[5]=y
11242 //sdci[6]=rotation
11243
11244 50406 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11245 50406 int32_t screen = sdci[3]/10000;
11246 50406 int32_t x = sdci[4]/10000;
11247 50406 int32_t y = sdci[5]/10000;
11248 50406 int32_t x1 = x + xoffset;
11249 50406 int32_t y1 = y + yoffset;
11250 50406 int32_t rotation = sdci[6]/10000;
11251
11252 50406 uint32_t index = (uint32_t)map_screen_index(map, screen);
11253
11254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(index >= TheMaps.size())
11255 {
11256 al_trace("DrawScreen: invalid map or screen index. \n");
11257 return;
11258 }
11259
11260 50406 const mapscr & m = TheMaps[index];
11261
11262
11263 50406 BITMAP* b = bmp;
11264
11265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(rotation != 0)
11266 b = script_drawing_commands.AquireSubBitmap(256, 176);
11267
11268 //draw layer 0
11269 50406 draw_mapscr(b, m, x1, y1, false);
11270
11271
2/2
✓ Branch 0 taken 50406 times.
✓ Branch 1 taken 302436 times.
352842 for(int32_t i(0); i < 6; ++i)
11272 {
11273
2/2
✓ Branch 0 taken 137944 times.
✓ Branch 1 taken 164492 times.
302436 if(m.layermap[i] == 0) continue;
11274
11275 137944 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11276
11277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137944 times.
137944 if(layer_screen_index >= TheMaps.size())
11278 continue;
11279
11280 137944 bool trans = m.layeropacity[i] == 128;
11281
11282 //draw valid layers
11283 137944 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
11284 137944 }
11285
11286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(rotation != 0) // rotate
11287 {
11288 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11289 script_drawing_commands.ReleaseSubBitmap(b);
11290 }
11291 50406 }
11292
11293
11294 143658 void do_bmpdrawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11295 {
11296 //sdci[1]=layer
11297 //sdci[2]=map
11298 //sdci[3]=screen
11299 //sdci[4]=layer
11300 //sdci[5]=x
11301 //sdci[6]=y
11302 //sdci[7]=rotation
11303 //[8] noclip
11304 //sdci[9]=opacity
11305 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11306
11307 143658 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11308
1/2
✓ Branch 0 taken 143658 times.
✗ Branch 1 not taken.
143658 if ( refbmp == NULL ) return;
11309
11310 143658 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11311 143658 int32_t screen = sdci[3]/10000;
11312 143658 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11313 143658 int32_t x = sdci[5]/10000;
11314 143658 int32_t y = sdci[6]/10000;
11315 143658 int32_t rotation = sdci[7]/10000;
11316
11317 143658 byte noclip = 0;//(sdci[8]!=0);
11318 143658 int32_t opacity = sdci[8]/10000;
11319 143658 uint32_t index = (uint32_t)map_screen_index(map, screen);
11320 143658 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11321
11322
2/2
✓ Branch 0 taken 102942 times.
✓ Branch 1 taken 40716 times.
143658 if(!m) //no need to log it.
11323 40716 return;
11324
11325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 if(index >= TheMaps.size())
11326 {
11327 Z_scripterrlog("DrawLayer: invalid map index \"%i\". Map count is %zu.\n", index, TheMaps.size());
11328 return;
11329 }
11330
11331 102942 const mapscr & l = *m;
11332
11333 102942 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11334
1/2
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
102942 if ( refbmp == NULL ) return;
11335
2/4
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102942 times.
✗ Branch 3 not taken.
102942 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11336
1/2
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
102942 if(rotation != 0)
11337 b = script_drawing_commands.AquireSubBitmap(256, 176);
11338
11339
11340 102942 const int32_t maxX = isOffScreen ? 512 : 256;
11341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11342 102942 bool transparent = opacity <= 128;
11343
11344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 if(rotation != 0) // rotate
11345 {
11346 draw_mapscr(b, l, x, y, transparent);
11347
11348 rotate_sprite(refbmp, b, x, y, degrees_to_fixed(rotation));
11349 script_drawing_commands.ReleaseSubBitmap(b);
11350 }
11351 else
11352 {
11353
2/2
✓ Branch 0 taken 18117792 times.
✓ Branch 1 taken 102942 times.
18220734 for(int32_t i(0); i < 176; ++i)
11354 {
11355 18117792 const int32_t x2 = ((i&15)<<4) + x;
11356 18117792 const int32_t y2 = (i&0xF0) + y;
11357
11358 //if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11359 {
11360 18117792 auto& c = GET_DRAWING_COMBO(l.data[i]);
11361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18117792 times.
18117792 if(c.animflags & AF_EDITOR_ONLY) continue;
11362 18117792 const int32_t tile = combo_tile(c, x2, y2);
11363
11364
2/2
✓ Branch 0 taken 37572 times.
✓ Branch 1 taken 18080220 times.
18117792 if(opacity < 128 != transparent_combo(l.data[i]))
11365 37572 overtiletranslucent16(refbmp, tile, x2, y2, l.cset[i], c.flip, opacity);
11366 else
11367 18080220 overtile16(refbmp, tile, x2, y2, l.cset[i], c.flip);
11368
11369 //putcombo( b, xx, yy, l.data[i], l.cset[i] );
11370 }
11371 18117792 }
11372 }
11373
11374 //putscr
11375 143658 }
11376
11377
11378
11379 2740 void do_bmpdrawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11380 {
11381 //sdci[1]=layer
11382 //sdci[2]=map
11383 //sdci[3]=screen
11384 //sdci[4]=x
11385 //sdci[5]=y
11386 //sdci[6]=rotation
11387 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11388
11389 2740 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11390
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if ( refbmp == NULL ) return;
11391
11392
2/4
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2740 times.
2740 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11393
11394 2740 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11395 2740 int32_t screen = sdci[3]/10000;
11396 2740 int32_t x = sdci[4]/10000;
11397 2740 int32_t y = sdci[5]/10000;
11398 2740 int32_t x1 = x + xoffset;
11399 2740 int32_t y1 = y + yoffset;
11400 2740 int32_t rotation = sdci[6]/10000;
11401
11402 2740 uint32_t index = (uint32_t)map_screen_index(map, screen);
11403
11404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2740 times.
2740 if(index >= TheMaps.size())
11405 {
11406 al_trace("DrawScreen: invalid map or screen index. \n");
11407 return;
11408 }
11409
11410 2740 const mapscr & m = TheMaps[index];
11411
11412
11413 2740 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2740 times.
2740 if ( refbmp == NULL ) return;
11415
11416
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if(rotation != 0)
11417 b = script_drawing_commands.AquireSubBitmap(256, 176);
11418
11419 //draw layer 0
11420 2740 draw_mapscr(b, m, x1, y1, false);
11421
11422
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 16440 times.
19180 for(int32_t i(0); i < 6; ++i)
11423 {
11424
2/2
✓ Branch 0 taken 8710 times.
✓ Branch 1 taken 7730 times.
16440 if(m.layermap[i] == 0) continue;
11425
11426 8710 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11427
11428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8710 times.
8710 if(layer_screen_index >= TheMaps.size())
11429 continue;
11430
11431 8710 bool trans = m.layeropacity[i] == 128;
11432
11433 //draw valid layers
11434 8710 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
11435 8710 }
11436
11437
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if(rotation != 0) // rotate
11438 {
11439 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11440 script_drawing_commands.ReleaseSubBitmap(b);
11441 }
11442 2740 }
11443
11444 void do_bmpdrawlayersolidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11445 {
11446 //sdci[1]=layer
11447 //sdci[2]=map
11448 //sdci[3]=screen
11449 //sdci[4]=layer
11450 //sdci[5]=x
11451 //sdci[6]=y
11452 //sdci[7]=rotation
11453 //sdci[8]=bool noclip
11454 //sdci[9] == opacity
11455
11456 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11457 int32_t screen = sdci[3]/10000;
11458 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11459 int32_t x = sdci[5]/10000;
11460 int32_t y = sdci[6]/10000;
11461 int32_t x1 = x + xoffset;
11462 int32_t y1 = y + yoffset;
11463 int32_t rotation = sdci[7]/10000;
11464 byte noclip = (sdci[8]!=0);
11465 int32_t opacity = sdci[9]/10000;
11466
11467 uint32_t index = (uint32_t)map_screen_index(map, screen);
11468 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11469
11470 if(!m) //no need to log it.
11471 return;
11472
11473 if(index >= TheMaps.size())
11474 {
11475 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11476 return;
11477 }
11478
11479 const mapscr & l = *m;
11480
11481 BITMAP* b = bmp;
11482
11483 if(rotation != 0)
11484 b = script_drawing_commands.AquireSubBitmap(256, 176);
11485
11486
11487 const int32_t maxX = isOffScreen ? 512 : 256;
11488 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11489 bool transparent = opacity <= 128;
11490
11491 if(rotation != 0) // rotate
11492 {
11493 draw_map_solid(b, l, x1, y1);
11494
11495 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11496 script_drawing_commands.ReleaseSubBitmap(b);
11497 }
11498 else
11499 {
11500 BITMAP* square = create_bitmap_ex(8,16,16);
11501 BITMAP* subsquare = create_bitmap_ex(8,16,16);
11502 clear_to_color(subsquare,1);
11503 for(int32_t i(0); i < 176; ++i)
11504 {
11505 const int32_t x2 = ((i&15)<<4) + x1;
11506 const int32_t y2 = (i&0xF0) + y1;
11507
11508 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11509 {
11510 int32_t sol = (combobuf[l.data[i]].walk);
11511
11512 if ( sol & 1 )
11513 {
11514 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
11515 }
11516 if ( sol & 2 )
11517 {
11518 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
11519 }
11520 if ( sol & 4 )
11521 {
11522 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
11523 }
11524 if ( sol &8 ) {
11525 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
11526 }
11527
11528 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11529 }
11530 }
11531 destroy_bitmap(square);
11532 destroy_bitmap(subsquare);
11533 }
11534
11535 //putscr
11536 }
11537
11538 void do_bmpdrawlayersolidityr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11539 {
11540 //sdci[1]=layer
11541 //sdci[2]=map
11542 //sdci[3]=screen
11543 //sdci[4]=layer
11544 //sdci[5]=x
11545 //sdci[6]=y
11546 //sdci[7]=rotation
11547 //[8] noclip
11548 //sdci[9]=opacity
11549
11550
11551 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11552 int32_t screen = sdci[3]/10000;
11553 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11554 int32_t x = sdci[5]/10000;
11555 int32_t y = sdci[6]/10000;
11556 int32_t x1 = x + xoffset;
11557 int32_t y1 = y + yoffset;
11558 int32_t rotation = sdci[7]/10000;
11559 byte noclip = (sdci[8]!=0);
11560 int32_t opacity = sdci[9]/10000;
11561
11562 uint32_t index = (uint32_t)map_screen_index(map, screen);
11563 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11564
11565 if(!m) //no need to log it.
11566 return;
11567
11568 if(index >= TheMaps.size())
11569 {
11570 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11571 return;
11572 }
11573
11574 const mapscr & l = *m;
11575
11576 BITMAP* b = bmp;
11577
11578 if(rotation != 0)
11579 b = script_drawing_commands.AquireSubBitmap(256, 176);
11580
11581
11582 const int32_t maxX = isOffScreen ? 512 : 256;
11583 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11584 bool transparent = opacity <= 128;
11585
11586 if(rotation != 0) // rotate
11587 {
11588 draw_map_solidity(b, l, x1, y1);
11589
11590 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11591 script_drawing_commands.ReleaseSubBitmap(b);
11592 }
11593 else
11594 {
11595 BITMAP* square = create_bitmap_ex(8,16,16);
11596 for(int32_t i(0); i < 176; ++i)
11597 {
11598 const int32_t x2 = ((i&15)<<4) + x1;
11599 const int32_t y2 = (i&0xF0) + y1;
11600
11601 if(noclip && (x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11602 {
11603 clear_to_color(square,(combobuf[l.data[i]].walk&15));
11604 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11605 }
11606 }
11607 destroy_bitmap(square);
11608 }
11609
11610 //putscr
11611 }
11612
11613 void do_bmpdrawlayercflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11614 {
11615 //sdci[1]=layer
11616 //sdci[2]=map
11617 //sdci[3]=screen
11618 //sdci[4]=layer
11619 //sdci[5]=x
11620 //sdci[6]=y
11621 //sdci[7]=rotation
11622 //[8] noclip
11623 //sdci[9]=opacity
11624
11625
11626 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11627 int32_t screen = sdci[3]/10000;
11628 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11629 int32_t x = sdci[5]/10000;
11630 int32_t y = sdci[6]/10000;
11631 int32_t x1 = x + xoffset;
11632 int32_t y1 = y + yoffset;
11633 int32_t rotation = sdci[7]/10000;
11634
11635 byte noclip = (sdci[8]!=0);
11636 int32_t opacity = sdci[9]/10000;
11637
11638 uint32_t index = (uint32_t)map_screen_index(map, screen);
11639 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11640
11641 if(!m) //no need to log it.
11642 return;
11643
11644 if(index >= TheMaps.size())
11645 {
11646 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11647 return;
11648 }
11649
11650 const mapscr & l = *m;
11651
11652 BITMAP* b = bmp;
11653
11654 if(rotation != 0)
11655 b = script_drawing_commands.AquireSubBitmap(256, 176);
11656
11657
11658 const int32_t maxX = isOffScreen ? 512 : 256;
11659 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11660 bool transparent = opacity <= 128;
11661
11662 if(rotation != 0) // rotate
11663 {
11664 draw_map_cflag(b, l, x1, y1);
11665
11666 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11667 script_drawing_commands.ReleaseSubBitmap(b);
11668 }
11669 else
11670 {
11671 BITMAP* square = create_bitmap_ex(8,16,16);
11672 for(int32_t i(0); i < 176; ++i)
11673 {
11674 const int32_t x2 = ((i&15)<<4) + x1;
11675 const int32_t y2 = (i&0xF0) + y1;
11676
11677 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11678 {
11679 clear_to_color(square,l.sflag[i]);
11680 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11681 }
11682 }
11683 destroy_bitmap(square);
11684 }
11685
11686 //putscr
11687 }
11688
11689 void do_bmpdrawlayerctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11690 {
11691 //sdci[1]=layer
11692 //sdci[2]=map
11693 //sdci[3]=screen
11694 //sdci[4]=layer
11695 //sdci[5]=x
11696 //sdci[6]=y
11697 //sdci[7]=rotation
11698 //[8] noclip
11699 //sdci[9]=opacity
11700
11701 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11702 int32_t screen = sdci[3]/10000;
11703 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11704 int32_t x = sdci[5]/10000;
11705 int32_t y = sdci[6]/10000;
11706 int32_t x1 = x + xoffset;
11707 int32_t y1 = y + yoffset;
11708 int32_t rotation = sdci[7]/10000;
11709
11710 byte noclip = (sdci[8]!=0);
11711 int32_t opacity = sdci[9]/10000;
11712 uint32_t index = (uint32_t)map_screen_index(map, screen);
11713 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11714
11715 if(!m) //no need to log it.
11716 return;
11717
11718 if(index >= TheMaps.size())
11719 {
11720 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11721 return;
11722 }
11723
11724 const mapscr & l = *m;
11725
11726 BITMAP* b = bmp;
11727
11728 if(rotation != 0)
11729 b = script_drawing_commands.AquireSubBitmap(256, 176);
11730
11731
11732 const int32_t maxX = isOffScreen ? 512 : 256;
11733 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11734 bool transparent = opacity <= 128;
11735
11736 if(rotation != 0) // rotate
11737 {
11738 draw_map_combotype(b, l, x1, y1);
11739
11740 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11741 script_drawing_commands.ReleaseSubBitmap(b);
11742 }
11743 else
11744 {
11745 BITMAP* square = create_bitmap_ex(8,16,16);
11746 for(int32_t i(0); i < 176; ++i)
11747 {
11748 const int32_t x2 = ((i&15)<<4) + x1;
11749 const int32_t y2 = (i&0xF0) + y1;
11750
11751 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11752 {
11753 clear_to_color(square,(combobuf[l.data[i]].type));
11754 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11755 }
11756 }
11757 destroy_bitmap(square);
11758 }
11759
11760 //putscr
11761 }
11762
11763 void do_bmpdrawlayerciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11764 {
11765 //sdci[1]=layer
11766 //sdci[2]=map
11767 //sdci[3]=screen
11768 //sdci[4]=layer
11769 //sdci[5]=x
11770 //sdci[6]=y
11771 //sdci[7]=rotation
11772 //[8] noclip
11773 //sdci[9]=opacity
11774
11775 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11776 int32_t screen = sdci[3]/10000;
11777 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11778 int32_t x = sdci[5]/10000;
11779 int32_t y = sdci[6]/10000;
11780 int32_t x1 = x + xoffset;
11781 int32_t y1 = y + yoffset;
11782 int32_t rotation = sdci[7]/10000;
11783 byte noclip = (sdci[8]!=0);
11784 int32_t opacity = sdci[9]/10000;
11785
11786 uint32_t index = (uint32_t)map_screen_index(map, screen);
11787 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11788
11789 if(!m) //no need to log it.
11790 return;
11791
11792 if(index >= TheMaps.size())
11793 {
11794 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11795 return;
11796 }
11797
11798 const mapscr & l = *m;
11799
11800 BITMAP* b = bmp;
11801
11802 if(rotation != 0)
11803 b = script_drawing_commands.AquireSubBitmap(256, 176);
11804
11805
11806 const int32_t maxX = isOffScreen ? 512 : 256;
11807 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11808 bool transparent = opacity <= 128;
11809
11810 if(rotation != 0) // rotate
11811 {
11812 draw_map_comboiflag(b, l, x1, y1);
11813
11814 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11815 script_drawing_commands.ReleaseSubBitmap(b);
11816 }
11817 else
11818 {
11819 BITMAP* square = create_bitmap_ex(8,16,16);
11820 for(int32_t i(0); i < 176; ++i)
11821 {
11822 const int32_t x2 = ((i&15)<<4) + x1;
11823 const int32_t y2 = (i&0xF0) + y1;
11824
11825 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11826 {
11827 clear_to_color(square,(combobuf[l.data[i]].flag));
11828 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11829 }
11830 }
11831 destroy_bitmap(square);
11832 }
11833
11834 //putscr
11835 }
11836
11837
11838
11839 /////////////////////////////////////////////////////////
11840 // do primitives
11841 ////////////////////////////////////////////////////////
11842
11843 // Draw commands can vary in terms of the origin/coordinate system to draw as. This
11844 // is controlled via `DrawOrigin`. Previous to `DrawOrigin`, this always drew
11845 // relative to the playing field (except for offscreen bitmaps).
11846 417511581 void do_primitives(BITMAP *targetBitmap, int32_t type)
11847 {
11848 417511581 do_primitives(targetBitmap, type, 0, playing_field_offset);
11849 417511581 }
11850
11851 418875029 void do_primitives(BITMAP *targetBitmap, int32_t type, int32_t xoff, int32_t yoff)
11852 {
11853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418875029 times.
418875029 if(type > 7)
11854 return;
11855
3/4
✓ Branch 0 taken 133756600 times.
✓ Branch 1 taken 285118429 times.
✓ Branch 2 taken 133756600 times.
✗ Branch 3 not taken.
418875029 if(type >= 0 && origin_scr->hidescriptlayers & (1<<type))
11856 return; //Script draws hidden for this layer
11857
2/2
✓ Branch 0 taken 4856981 times.
✓ Branch 1 taken 414018048 times.
418875029 if(!script_drawing_commands.is_dirty(type))
11858 414018048 return; //No draws to this layer
11859
11860 4856981 color_map = trans_table2;
11861 //--script_drawing_commands[][] reference--
11862 //[][0]: type
11863 //[][1-16]: defined by type
11864 //...
11865 //[][DRAWCMD_BMP_TARGET]: bitmap pointer
11866 //[][DRAWCMD_CURRENT_TARGET]: current render target at time command is queued? unused?
11867
11868 4856981 const int32_t type_mul_10000 = type * 10000;
11869 4856981 const int32_t numDrawCommandsToProcess = script_drawing_commands.Count();
11870 4856981 FFCore.numscriptdraws = numDrawCommandsToProcess;
11871
11872
2/2
✓ Branch 0 taken 372521749 times.
✓ Branch 1 taken 4856981 times.
377378730 for (int i = 0; i < numDrawCommandsToProcess; i++)
11873 {
11874 372521749 auto& command = script_drawing_commands[i];
11875 372521749 int32_t *sdci = &script_drawing_commands[i][0];
11876
11877
2/2
✓ Branch 0 taken 247981481 times.
✓ Branch 1 taken 124540268 times.
372521749 if (sdci[1] != type_mul_10000)
11878 247981481 continue;
11879
11880 124540268 DrawOrigin draw_origin = command.draw_origin;
11881
11882 // get the correct render target, if set via Screen->SetRenderTarget
11883 // Note: This is a deprecated feature.
11884 124540268 BITMAP *bmp = zscriptDrawingRenderTarget->GetTargetBitmap(sdci[DRAWCMD_CURRENT_TARGET]);
11885 bool isTargetOffScreenBmp;
11886
11887
2/2
✓ Branch 0 taken 6478283 times.
✓ Branch 1 taken 118061985 times.
124540268 if(!bmp)
11888 {
11889 118061985 bmp = targetBitmap;
11890 118061985 isTargetOffScreenBmp = false;
11891 118061985 }
11892 else
11893 {
11894 // Render target was set to a internal bitmap (but not the screen bitmap).
11895 6478283 isTargetOffScreenBmp = true;
11896 6478283 draw_origin = DrawOrigin::Screen;
11897 }
11898
11899 124540268 current_target_bmp = bmp;
11900
11901 int xoffset, yoffset;
11902
1/2
✓ Branch 0 taken 124540268 times.
✗ Branch 1 not taken.
124540268 if (auto r = get_draw_origin_offset(draw_origin, command.draw_origin_target, xoff, yoff))
11903 {
11904 124540268 std::tie(xoffset, yoffset) = *r;
11905 124540268 }
11906 else
11907 {
11908 continue;
11909 }
11910
11911 124540268 secondary_draw_origin_xoff = 0;
11912 124540268 secondary_draw_origin_yoff = 0;
11913
2/2
✓ Branch 0 taken 122745042 times.
✓ Branch 1 taken 1795226 times.
124540268 if (command.secondary_draw_origin != DrawOrigin::Default)
11914 {
11915
1/2
✓ Branch 0 taken 1795226 times.
✗ Branch 1 not taken.
1795226 if (auto r = get_draw_origin_offset(command.secondary_draw_origin, command.secondary_draw_origin_target, xoff, yoff))
11916 {
11917 1795226 std::tie(secondary_draw_origin_xoff, secondary_draw_origin_yoff) = *r;
11918 1795226 }
11919 else
11920 {
11921 continue;
11922 }
11923 1795226 }
11924
11925
40/87
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3344855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1170681 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1850 times.
✓ Branch 7 taken 2351475 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 404879 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 2302534 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2761920 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5327982 times.
✓ Branch 19 taken 30256034 times.
✓ Branch 20 taken 964155 times.
✓ Branch 21 taken 176452 times.
✓ Branch 22 taken 1607511 times.
✓ Branch 23 taken 201739 times.
✓ Branch 24 taken 9266 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1080 times.
✓ Branch 29 taken 937483 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 4370235 times.
✓ Branch 32 taken 50406 times.
✓ Branch 33 taken 12431 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 192290 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 502 times.
✓ Branch 38 taken 144 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 80910 times.
✓ Branch 41 taken 64994 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 11288 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 1982263 times.
✓ Branch 46 taken 41542691 times.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 865 times.
✓ Branch 50 taken 45504 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 143658 times.
✓ Branch 57 taken 2740 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 60 taken 1024 times.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✓ Branch 63 taken 2062708 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 113653 times.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 72 taken 2134433 times.
✓ Branch 73 taken 34749 times.
✓ Branch 74 taken 43007 times.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✓ Branch 80 taken 19821648 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 7323 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 906 times.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
124540268 switch(sdci[0])
11926 {
11927 case RECTR:
11928 {
11929 3344855 do_rectr(bmp, sdci, xoffset, yoffset);
11930 }
11931 3344855 break;
11932 case FRAMER:
11933 {
11934 do_framer(bmp, sdci, xoffset, yoffset);
11935 }
11936 break;
11937
11938
11939 case CIRCLER:
11940 {
11941 1170681 do_circler(bmp, sdci, xoffset, yoffset);
11942 }
11943 1170681 break;
11944
11945 case ARCR:
11946 {
11947 do_arcr(bmp, sdci, xoffset, yoffset);
11948 }
11949 break;
11950
11951 case ELLIPSER:
11952 {
11953 1850 do_ellipser(bmp, sdci, xoffset, yoffset);
11954 }
11955 1850 break;
11956
11957 case LINER:
11958 {
11959 2351475 do_liner(bmp, sdci, xoffset, yoffset);
11960 }
11961 2351475 break;
11962
11963 case SPLINER:
11964 {
11965 do_spliner(bmp, sdci, xoffset, yoffset);
11966 }
11967 break;
11968
11969 case PUTPIXELR:
11970 {
11971 404879 do_putpixelr(bmp, sdci, xoffset, yoffset);
11972 }
11973 404879 break;
11974 case PIXELARRAYR:
11975 {
11976 do_putpixelsr(bmp, i, sdci, xoffset, yoffset);
11977 }
11978 break;
11979
11980 case TILEARRAYR:
11981 {
11982 do_fasttilesr(bmp, i, sdci, xoffset, yoffset);
11983 }
11984 break;
11985
11986 case LINESARRAY:
11987 {
11988 do_linesr(bmp, i, sdci, xoffset, yoffset);
11989 }
11990 break;
11991
11992 case COMBOARRAYR:
11993 {
11994 do_fastcombosr(bmp, i, sdci, xoffset, yoffset);
11995 }
11996 break;
11997
11998
11999
12000 case DRAWTILER:
12001 {
12002 2302534 do_drawtiler(bmp, sdci, xoffset, yoffset);
12003 }
12004 2302534 break;
12005
12006 case DRAWTILECLOAKEDR:
12007 {
12008 do_drawtilecloakedr(bmp, sdci, xoffset, yoffset);
12009 }
12010 break;
12011
12012 case DRAWCOMBOR:
12013 {
12014 2761920 do_drawcombor(bmp, sdci, xoffset, yoffset);
12015 }
12016 2761920 break;
12017
12018 case DRAWCOMBOCLOAKEDR:
12019 {
12020 do_drawcombocloakedr(bmp, sdci, xoffset, yoffset);
12021 }
12022 break;
12023
12024 case FASTTILER:
12025 {
12026 5327982 do_fasttiler(bmp, sdci, xoffset, yoffset);
12027 }
12028 5327982 break;
12029
12030 case FASTCOMBOR:
12031 {
12032 30256034 do_fastcombor(bmp, sdci, xoffset, yoffset);
12033 }
12034 30256034 break;
12035
12036 case DRAWCHARR:
12037 {
12038 964155 do_drawcharr(bmp, sdci, xoffset, yoffset);
12039 }
12040 964155 break;
12041
12042 case DRAWINTR:
12043 {
12044 176452 do_drawintr(bmp, sdci, xoffset, yoffset);
12045 }
12046 176452 break;
12047
12048 case DRAWSTRINGR:
12049 {
12050 1607511 do_drawstringr(bmp, i, sdci, xoffset, yoffset);
12051 }
12052 1607511 break;
12053
12054 case DRAWSTRINGR2:
12055 {
12056 201739 do_drawstringr2(bmp, i, sdci, xoffset, yoffset);
12057 }
12058 201739 break;
12059
12060 case QUADR:
12061 {
12062 9266 do_drawquadr(bmp, sdci, xoffset, yoffset);
12063 }
12064 9266 break;
12065
12066 case QUAD3DR:
12067 {
12068 do_drawquad3dr(bmp, i, sdci, xoffset, yoffset);
12069 }
12070 break;
12071
12072 case TRIANGLER:
12073 {
12074 do_drawtriangler(bmp, sdci, xoffset, yoffset);
12075 }
12076 break;
12077
12078 case TRIANGLE3DR:
12079 {
12080 do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset);
12081 }
12082 break;
12083
12084 case POLYGONR:
12085 {
12086 1080 do_polygonr(bmp, i, sdci, xoffset, yoffset);
12087 }
12088 1080 break;
12089
12090
12091 case BITMAPR:
12092 {
12093 937483 do_drawbitmapr(bmp, sdci, xoffset, yoffset);
12094 }
12095 937483 break;
12096
12097 case BITMAPEXR:
12098 {
12099 do_drawbitmapexr(bmp, sdci, xoffset, yoffset);
12100 }
12101 break;
12102
12103 case DRAWLAYERR:
12104 {
12105 4370235 do_drawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
12106 }
12107 4370235 break;
12108
12109 case DRAWSCREENR:
12110 {
12111 50406 do_drawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
12112 }
12113 50406 break;
12114
12115 12431 case BMPRECTR: bmp_do_rectr(bmp, sdci, xoffset, yoffset); break;
12116 case BMPFRAMER: bmp_do_framer(bmp, sdci, xoffset, yoffset); break;
12117 192290 case BMPCIRCLER: bmp_do_circler(bmp, sdci, xoffset, yoffset); break;
12118 case BMPARCR: bmp_do_arcr(bmp, sdci, xoffset, yoffset); break;
12119 502 case BMPELLIPSER: bmp_do_ellipser(bmp, sdci, xoffset, yoffset); break;
12120 144 case BMPLINER: bmp_do_liner(bmp, sdci, xoffset, yoffset); break;
12121 case BMPSPLINER: bmp_do_spliner(bmp, sdci, xoffset, yoffset); break;
12122 80910 case BMPPUTPIXELR: bmp_do_putpixelr(bmp, sdci, xoffset, yoffset); break;
12123 64994 case BMPDRAWTILER: bmp_do_drawtiler(bmp, sdci, xoffset, yoffset); break;
12124 case BMPDRAWTILECLOAKEDR: bmp_do_drawtilecloakedr(bmp, sdci, xoffset, yoffset); break;
12125 11288 case BMPDRAWCOMBOR: bmp_do_drawcombor(bmp, sdci, xoffset, yoffset); break;
12126 case BMPDRAWCOMBOCLOAKEDR: bmp_do_drawcombocloakedr(bmp, sdci, xoffset, yoffset); break;
12127 1982263 case BMPFASTTILER: bmp_do_fasttiler(bmp, sdci, xoffset, yoffset); break;
12128 41542691 case BMPFASTCOMBOR: bmp_do_fastcombor(bmp, sdci, xoffset, yoffset); break;
12129 case BMPDRAWCHARR: bmp_do_drawcharr(bmp, sdci, xoffset, yoffset); break;
12130 case BMPDRAWINTR: bmp_do_drawintr(bmp, sdci, xoffset, yoffset); break;
12131 865 case BMPDRAWSTRINGR: bmp_do_drawstringr(bmp, i, sdci, xoffset, yoffset); break;
12132 45504 case BMPDRAWSTRINGR2: bmp_do_drawstringr2(bmp, i, sdci, xoffset, yoffset); break;
12133 case BMPQUADR: bmp_do_drawquadr(bmp, sdci, xoffset, yoffset); break;
12134 case BMPQUAD3DR: bmp_do_drawquad3dr(bmp, i, sdci, xoffset, yoffset); break;
12135 case BMPTRIANGLER: bmp_do_drawtriangler(bmp, sdci, xoffset, yoffset); break;
12136 case BMPTRIANGLE3DR: bmp_do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset); break;
12137 case BMPPOLYGONR: bmp_do_polygonr(bmp, i, sdci, xoffset, yoffset); break;
12138 143658 case BMPDRAWLAYERR: do_bmpdrawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12139 2740 case BMPDRAWSCREENR: do_bmpdrawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12140 case BMPDRAWSCREENSOLIDR: do_bmpdrawscreen_solidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12141 case BMPDRAWSCREENSOLID2R: do_bmpdrawscreen_solidr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12142 1024 case BMPDRAWSCREENCOMBOFR: do_bmpdrawscreen_cflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12143 case BMPDRAWSCREENCOMBOIR: do_bmpdrawscreen_ciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12144 case BMPDRAWSCREENCOMBOTR: do_bmpdrawscreen_ctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12145 2062708 case BMPBLIT: bmp_do_drawbitmapexr(bmp, sdci, xoffset, yoffset); break;
12146 case BMPMODE7: bmp_do_mode7r(bmp, sdci, xoffset, yoffset); break;
12147 113653 case BMPBLITTO: bmp_do_blittor(bmp, sdci, xoffset, yoffset); break;
12148 case TILEBLIT: do_tileblit(bmp, sdci, xoffset, yoffset, false, "TileBlit()"); break;
12149 case COMBOBLIT: do_comboblit(bmp, sdci, xoffset, yoffset, false); break;
12150 case BMPTILEBLIT: do_tileblit(bmp, sdci, xoffset, yoffset, true, "TileBlit()"); break;
12151 case BMPCOMBOBLIT: do_comboblit(bmp, sdci, xoffset, yoffset, true); break;
12152 case READBITMAP: bmp_do_readr(bmp, i, sdci, xoffset, yoffset); break;
12153 case WRITEBITMAP: bmp_do_writer(bmp, i, sdci, xoffset, yoffset); break;
12154 2134433 case CLEARBITMAP: bmp_do_clearr(bmp, sdci, xoffset, yoffset); break;
12155 34749 case BITMAPCLEARTOCOLOR: bmp_do_clearcolorr(bmp, sdci, xoffset, yoffset); break;
12156 43007 case REGENERATEBITMAP: bmp_do_regenr(bmp, sdci, xoffset, yoffset); break;
12157
12158 case BMPDRAWLAYERSOLIDR: do_bmpdrawlayersolidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12159 case BMPDRAWLAYERCFLAGR: do_bmpdrawlayercflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12160 case BMPDRAWLAYERCTYPER: do_bmpdrawlayerctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12161 case BMPDRAWLAYERCIFLAGR: do_bmpdrawlayerciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12162 case BMPDRAWLAYERSOLIDITYR: do_bmpdrawlayersolidityr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12163 19821648 case BMPWRITETILE: do_bmpwritetile(bmp, sdci, xoffset, yoffset); break;
12164 case BMPDITHER: do_bmpdither(bmp, sdci, xoffset, yoffset); break;
12165 7323 case BMPREPLCOLOR: do_bmpreplcol(bmp, sdci, xoffset, yoffset); break;
12166 case BMPSHIFTCOLOR: do_bmpshiftcol(bmp, sdci, xoffset, yoffset); break;
12167 906 case BMPMASKDRAW: do_bmpmaskdraw(bmp, sdci, xoffset, yoffset); break;
12168 case BMPMASKBLIT: do_bmpmaskblit(bmp, sdci, xoffset, yoffset); break;
12169
12170 // The following are special cases, in that the target bitmap is fixed (darkscr_bmp).
12171
12172 case DRAWLIGHT_CONE:
12173 {
12174 int32_t cx = sdci[2]/10000 + xoffset;
12175 int32_t cy = sdci[3]/10000 + yoffset;
12176 int32_t dir = sdci[4]/10000;
12177 int32_t length = sdci[5];
12178 int32_t transp_rad = sdci[6];
12179 int32_t dith_rad = sdci[7];
12180 int32_t dith_type = sdci[8];
12181 int32_t dith_arg = sdci[9];
12182
12183 if(length >= 0) length /= 10000;
12184 else length = game->get_light_rad()*2;
12185 if(!length) break;
12186 if(dir < 0) break;
12187 else dir = NORMAL_DIR(dir);
12188 if(transp_rad >= 0) transp_rad /= 10000;
12189 if(dith_rad >= 0) dith_rad /= 10000;
12190 if(dith_type >= 0) dith_type /= 10000;
12191 if(dith_arg >= 0) dith_arg /= 10000;
12192
12193 // Undo the inherit offset applied within the function. xoffset/yoffset handles for us here.
12194 cx += viewport.x;
12195 cy += viewport.y;
12196
12197 doDarkroomCone(cx,cy,length,dir,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12198 }
12199 break;
12200
12201 case DRAWLIGHT_CIRCLE:
12202 case DRAWLIGHT_SQUARE:
12203 {
12204 int32_t cx = sdci[2]/10000 + xoffset;
12205 int32_t cy = sdci[3]/10000 + yoffset;
12206 int32_t radius = sdci[4];
12207 int32_t transp_rad = sdci[5];
12208 int32_t dith_rad = sdci[6];
12209 int32_t dith_type = sdci[7];
12210 int32_t dith_arg = sdci[8];
12211
12212 if(radius >= 0) radius /= 10000;
12213 else radius = game->get_light_rad();
12214 if(!radius) break;
12215 if(transp_rad >= 0) transp_rad /= 10000;
12216 if(dith_rad >= 0) dith_rad /= 10000;
12217 if(dith_type >= 0) dith_type /= 10000;
12218 if(dith_arg >= 0) dith_arg /= 10000;
12219
12220 // Undo the inherit offset applied within the function. xoffset/yoffset handles for us here.
12221 cx += viewport.x;
12222 cy += viewport.y;
12223
12224 if (sdci[0] == DRAWLIGHT_CIRCLE)
12225 doDarkroomCircle(cx,cy,radius,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12226 else
12227 doDarkroomSquare(cx,cy,radius,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12228 }
12229 break;
12230 }
12231 124540268 }
12232
12233
12234 4856981 color_map=trans_table;
12235 418875029 }
12236
12237 16869425 void CScriptDrawingCommands::Clear()
12238 {
12239 16869425 scb.update();
12240 16869425 dirty_layers.clear();
12241
2/2
✓ Branch 0 taken 11519846 times.
✓ Branch 1 taken 5349579 times.
16869425 if(commands.empty())
12242 11519846 return;
12243
12244 //only clear what was used.
12245 5349579 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
12246 5349579 count = 0;
12247
12248 5349579 draw_container.Clear();
12249 16869425 }
12250 CScriptDrawingCommands* CScriptDrawingCommands::pop_commands()
12251 {
12252 CScriptDrawingCommands* ret = new CScriptDrawingCommands();
12253 if(commands.empty())
12254 return ret;
12255 ret->push_commands(this, false);
12256
12257 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
12258 count = 0;
12259
12260 draw_container.Clear();
12261 return ret;
12262 }
12263 void CScriptDrawingCommands::push_commands(CScriptDrawingCommands* other, bool del)
12264 {
12265 commands.insert(commands.end(), other->commands.begin(), other->commands.end());
12266 count += other->count;
12267 if(del) delete other;
12268 }
12269
12270 vector<int> CScriptDrawingCommands::get_dirty_layers_in_range(int min, int max)
12271 {
12272 vector<int> ret;
12273 for(int layer : dirty_layers)
12274 {
12275 if(layer < min) continue;
12276 if(layer > max) break;
12277 ret.push_back(layer);
12278 }
12279 return ret;
12280 }
12281
12282 170431 void do_script_draws(BITMAP *targetBitmap, mapscr* scr, int32_t xoff, int32_t yoff, bool hideLayer7)
12283 {
12284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170431 times.
170431 if(get_qr(qr_CLASSIC_DRAWING_ORDER))
12285
2/2
✓ Branch 0 taken 168921 times.
✓ Branch 1 taken 1510 times.
171941 if(XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12286 1510 do_primitives(targetBitmap, 2, xoff, yoff);
12287
2/2
✓ Branch 0 taken 163220 times.
✓ Branch 1 taken 7211 times.
170431 if(XOR(scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG))
12288 7211 do_primitives(targetBitmap, 3, xoff, yoff);
12289
1/2
✓ Branch 0 taken 170431 times.
✗ Branch 1 not taken.
170431 if(!get_qr(qr_CLASSIC_DRAWING_ORDER))
12290 if(XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12291 do_primitives(targetBitmap, 2, xoff, yoff);
12292 170431 do_primitives(targetBitmap, 0, xoff, yoff);
12293 170431 do_primitives(targetBitmap, 1, xoff, yoff);
12294
2/2
✓ Branch 0 taken 1510 times.
✓ Branch 1 taken 168921 times.
170431 if(!XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12295 168921 do_primitives(targetBitmap, 2, xoff, yoff);
12296
2/2
✓ Branch 0 taken 7211 times.
✓ Branch 1 taken 163220 times.
170431 if(!XOR(scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG))
12297 163220 do_primitives(targetBitmap, 3, xoff, yoff);
12298 170431 do_primitives(targetBitmap, 4, xoff, yoff);
12299 170431 do_primitives(targetBitmap, 5, xoff, yoff);
12300 170431 do_primitives(targetBitmap, 6, xoff, yoff);
12301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170431 times.
170431 if(!hideLayer7) do_primitives(targetBitmap, 7, xoff, yoff);
12302 170431 }
12303